Skip to Content
GraphQL Tools
DocumentationMigrationFrom GraphQL Import

Migration from GraphQL Import

GraphQL Import was an NPM package that allows you to import and export definitions using #import syntax in .graphql files. So this package has been moved under GraphQL Tools monorepo. It is really easy to migrate. You need two different packages @graphql-tools/load and @graphql-tools/graphql-file-loader.

Before

import { join } from 'node:path' import { importSchema } from 'graphql-import' import { makeExecutableSchema } from 'graphql-tools' const typeDefs = importSchema(join(__dirname, 'schema.graphql')) const resolvers = { Query: { // ... } } const schema = makeExecutableSchema({ typeDefs, resolvers })

After

import { join } from 'node:path' import { GraphQLFileLoader } from '@graphql-tools/graphql-file-loader' import { loadSchemaSync } from '@graphql-tools/load' import { addResolversToSchema } from '@graphql-tools/schema' const schema = loadSchemaSync(join(__dirname, 'schema.graphql'), { loaders: [new GraphQLFileLoader()] }) const resolvers = { Query: { // ... } } const schemaWithResolvers = addResolversToSchema({ schema, resolvers })
💡

You can learn more about those new packages in Schema Loading section.

Last updated on