Migration from Yoga V2
GraphQL Yoga v3 documentation (superseded by v5): Now GraphQL Yoga has a single NPM package for all environments `graphql-yoga` instead of `@graphql-yoga/common` and `@graphql-yoga/node`.
Install the new NPM package
Now GraphQL Yoga has a single NPM package for all environments graphql-yoga instead of
@graphql-yoga/common and @graphql-yoga/node. So you need to uninstall @graphql-yoga/common and
@graphql-yoga/node then install graphql-yoga from NPM.
createServer renamed to createYoga
In order to prevent the confusion, we decided to rename createServer function to createYoga.
createSchema for executable schemas
With Yoga v2 you could pass the typeDefs and resolvers directly to the server options and have
@graphql-tools/schema generate the executable schema
during setup.
However, Yoga v3 accepts only a ready GraphQL schema and instead offers a seperate
helper function createSchema to supplement this process.
handleIncomingMessage renamed to handleNodeRequest
For some frameworks, we need to use this low-level function such as Fastify and Koa. So you can
basically rename the method to handleNodeRequest.
No more .start and .stop
Previously on Node and CF/Service Workers environments, Yoga handles server processes with .start
and .stop methods together with some environment specific server configurations. Yoga no longer
deals with HTTP server configuration so the following changes needed;
For Node
For CF/Service Workers
No more Node specific multipart configuration
Previously it was possible to configure limitations of multipart request processing in
@graphql-yoga/node package but now graphql-yoga package is completely platform agnostic and we
avoid to have any Node specific configuration in GraphQL Yoga. But it is still possible to keep the
same behavior by configuring @whatwg-node/fetch which is used by GraphQL Yoga internally for
Node.js.
Removed endpoint and graphiql.endpoint options
In v2, there is endpoint option which is used to configure the GraphQL endpoint, and
graphiql.endpoint to point GraphiQL to a different GraphQL API. Now they are removed in favor
graphqlEndpoint option. If you want to use YogaGraphiQL for a different GraphQL endpoint, you
can use @graphql-yoga/render-graphiql package separately.
No more GraphQLYogaError, use GraphQLError instead
In v2, we introduced a new error class GraphQLYogaError which is a subclass of GraphQLError and
it is now deprecated in favor of GraphQLError. So in resolvers, you can use it in the same way but
the second parameter of GraphQLError constructor is not extensions but an object that contains
more options for GraphQLError. You can basically do the following change;
Also you can change the status code and headers of the error response by using the extensions
object.
No more readinessCheckEndpoint, consider using the useReadinessCheck plugin instead
A readiness health check is not something Yoga can accurately perform as it requires user-land context. Read more about the new health check.
Update options for useMaskedErrors plugin
- Removed
handleValidationErrorsandhandleParseErrorsoptions - Rename
formatErrortomaskError
Checkout envelop docs for more details.
Removed .inject method
Previously we provided .inject method to mock HTTP requests for testing purposes. Now you can use
the fetch method on your yoga instance for calling the yoga instance as if you were doing an HTTP
request.