-
Notifications
You must be signed in to change notification settings - Fork 2k
docs: move migrate from express graphql guide to graphqlJS docs #4433
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
base: 16.x.x
Are you sure you want to change the base?
Conversation
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.
Thanks for all your amazing work on the docs! Made a few scattered comments just to think about.
Thank you @yaacovCR for your thoughtful feedback! I have addressed it in my recent commit. Let me know if you spot anything else :) |
support for features like `@defer` and `@stream` is still evolving. These capabilities are experimental in both `graphql-js` | ||
and `graphql-http`, and may require additional setup. | ||
|
||
- Most GraphQL clients don’t yet support multipart responses. |
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'm not sure if this is true! It might be!
and `graphql-http`, and may require additional setup. | ||
|
||
- Most GraphQL clients don’t yet support multipart responses. | ||
- Server-side support for streaming may be incomplete or inconsistent. |
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 don't think it's supported at all within graphql-http
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.
graphql-http does not support anything streaming.
Co-authored-by: Yaacov Rydzinski <yaacovCR@gmail.com>
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.
Really nice article. Maybe the "Consider IDE support in development" section wants removing or merging with the "Step 5: Add a GraphQL IDE (optional)" section?
@enisdenjo can you sign off on the accuracy of the steps provided?
If @enisdenjo confirms the migration steps look good, I approve 👍 |
Install the core `graphql-http` package along with its Express adapter: | ||
|
||
```bash | ||
npm install graphql graphql-http @graphql-http/express |
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.
@graphql-http/express
does not exist.
npm install graphql graphql-http @graphql-http/express | |
npm install graphql graphql-http |
``` | ||
|
||
- Use `app.all()` to allow both `GET` and `POST` requests. | ||
- The handler accepts an options object similar to `express-graphql`. |
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.
Well, not completely similar. Only for stuff related to graphql like the schema, rootValue, subscribe/execute fns, etc. - but server related configurations are different.
context: async (req, res) => { | ||
return { user: await authenticate(req) }; | ||
}, | ||
formatError: (error) => ({ |
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.
You cannot return a plain object. Instace of Error
or GraphQLError
.
https://github.com/graphql/graphql-http/blob/main/docs/modules/handler.md#formaterror
``` | ||
|
||
- `context` can be a static object or an async function. | ||
- You can also pass `rootValue`, or extend responses with custom logic. |
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.
Extending responses happens outside of graphql-http, it itself does not have any options to change the response.
|
||
### Consider IDE support in development | ||
|
||
`express-graphql` includes GraphiQL by default in development mode. `graphql-http` does not. |
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.
Repeated, maybe mention or link?
and `graphql-http`, and may require additional setup. | ||
|
||
- Most GraphQL clients don’t yet support multipart responses. | ||
- Server-side support for streaming may be incomplete or inconsistent. |
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.
graphql-http does not support anything streaming.
- Most GraphQL clients don’t yet support multipart responses. | ||
- Server-side support for streaming may be incomplete or inconsistent. | ||
- If your app relies on incremental delivery, consider using a transport library like | ||
[`graphql-sse`](https://github.com/enisdenjo/graphql-sse) instead. |
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 wont work with graphql-http. You need to use graphql-sse on the server too, please mention that to avoid confusion.
Resolves this feedback: graphql/graphql.github.io#2005 (review)
Moving Migrate from express graphQL guide to graphQL-js