-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TypeScript examples to all subscriptions page code blocks #11977
Conversation
|
size-limit report 📦
|
1450844
to
e741899
Compare
✅ Deploy Preview for apollo-client-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for apollo-client-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
const COMMENTS_SUBSCRIPTION: TypedDocumentNode< | ||
OnCommentAddedSubscription, | ||
OnCommentAddedSubscriptionVariables | ||
> = gql` | ||
subscription OnCommentAdded($postID: ID!) { | ||
commentAdded(postID: $postID) { | ||
id | ||
content | ||
} | ||
} | ||
`; | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit sad that we don't seem to have graphql code highlighting in .ts
mode. Not that this PR would change anything, just wanted to mention it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Would love to dig into this further if I have some time.
subscription OnCommentAdded($postID: ID!) { | ||
commentAdded(postID: $postID) { | ||
id | ||
content | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Irritatingly, here the transpiled-to-js gql
tag also doesn't have syntax highlighting, while the manual js
block above does... maybe worth investigating?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Closes #10184
Adds
TypeScript
examples to all code blocks on the subscriptions page. You'll note that some<MultiCodeBlock />
components only specify TS and others specify both. The ones that only specify TS will compile and add a JS block as well, but I found some bugs in some places with formatting and spacing so some code blocks specify both TS and JS code blocks to avoid the auto-compilation.This change assumes that we want
TypedDocumentNode
as the predominant pattern for declaring types on query documents. The original issue mentions using the generic argument syntax forsubscribeToMore
, but I left that out in favor of the typed document node instead.