Migration from Apollo Server#
Installation#
You can start with installing graphql-yoga
package.
yarn add @graphql-yoga/node
pnpm add @graphql-yoga/node
npm install @graphql-yoga/node
Install equivalent Envelop plugins of the Apollo Server#
Some features that are included within apollo-server by default must be installed as envelop plugins (Learn more about envelop plugins here).
- Apollo Federation
- If you are using Apollo Federation, install
@envelop/use-apollo-federation
- If you are using Apollo Federation, install
- Apollo Server Errors
- If you are using Apollo Server errors, install
@envelop/use-apollo-server-errors
- If you are using Apollo Server errors, install
- Apollo Tracing
- If you are using Apollo Tracing, install
@envelop/use-apollo-tracing
- If you are using Apollo Tracing, install
- Response Cache
- If you are using Response Cache, you should set up
@envelop/use-response-cache
for the same functionality
- If you are using Response Cache, you should set up
Check out more plugins on Envelop Plugin Hub
Example initial usage of GraphQL Yoga#
For example if you are using Apollo Server Errors;
apollo-server-errors-example.ts
import { schema } from './schema'
- import { ApolloServer } from 'apollo-server'
+ import { createServer } from '@graphql-yoga/node'
+ import { useApolloServerErrors } from '@envelop/apollo-server-errors'
- const server = new ApolloServer({
+ const server = createServer({
// You can also pass `typeDefs` and `resolvers` here directly if you previously use `ApolloServer` constructor to build your `GraphQLSchema`
// schema: { typeDefs, resolvers },
schema,
+ plugins: [useApolloServerErrors()],
})
server.start()
Migration from standalone apollo-server
#
You don't need anything special. You can just use GraphQL Yoga as in the example above.
Migration from apollo-server-*
#
Check the integration section to choose the server framework you are using with Apollo Server.
For example, if you are using Express, you should remove server.start()
from the code above and replace server.applyMiddleware({ app })
with the route as in Express Integration section
- server.applyMiddleware({ app })
+ app.use('/graphql', server)