Skip to content

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

Open
wants to merge 4 commits into
base: 16.x.x
Choose a base branch
from

Conversation

sarahxsanders
Copy link
Contributor

Resolves this feedback: graphql/graphql.github.io#2005 (review)

Moving Migrate from express graphQL guide to graphQL-js

Copy link
Contributor

@yaacovCR yaacovCR left a 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.

@sarahxsanders
Copy link
Contributor Author

Thank you @yaacovCR for your thoughtful feedback! I have addressed it in my recent commit. Let me know if you spot anything else :)

@sarahxsanders sarahxsanders requested a review from yaacovCR June 10, 2025 23:37
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.
Copy link
Contributor

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.
Copy link
Contributor

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

Copy link
Member

@enisdenjo enisdenjo Jun 13, 2025

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>
Copy link
Member

@benjie benjie left a 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?

@benjie
Copy link
Member

benjie commented Jun 12, 2025

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
Copy link
Member

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.

Suggested change
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`.
Copy link
Member

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) => ({
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

@enisdenjo enisdenjo Jun 13, 2025

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.
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants