Docs
Launch GraphOS Studio
Apollo Server 2 is officially end-of-life as of 22 October 2023. Learn more about upgrading.

Using a different version of graphql-tools


includes graphql-tools version 4 by default. If you want to use a newer version, you can do so with the following steps:

  1. Install graphql-tools separately in your project.

  2. Update your ApolloServer constructor to provide the schema option instead of typeDefs, resolvers, and schemaDirectives. You instead pass these options to the makeExecutableSchema function, which you provide as the value of schema:

    index.js
    const { ApolloServer, gql } = require("apollo-server");
    const { makeExecutableSchema } = require("@graphql-tools/schema");
    const server = new ApolloServer({
    schema: makeExecutableSchema({
    typeDefs,
    resolvers,
    schemaDirectives: {
    // ...directive subclasses...
    }
    }),
    // ...other options...
    });
  3. Add the following definitions to your schema typeDefs:

    schema.graphql
    enum CacheControlScope {
    PUBLIC
    PRIVATE
    }
    directive @cacheControl(
    maxAge: Int
    scope: CacheControlScope
    ) on FIELD_DEFINITION | OBJECT | INTERFACE
    scalar Upload

    uses these types for its

    and
    file upload
    functionality. It usually defines these types automatically on startup, but it doesn't if you provide the schema option to the ApolloServer constructor.

For more information on the latest version of graphql-tools, see the

.

Previous
Proxy configuration
Next
File uploads in Node.js < v8.5.0
Edit on GitHubEditForumsDiscord

© 2024 Apollo Graph Inc.

Privacy Policy

Company