This package has been deprecated

Author message:

GraphQL Import has been deprecated and merged into GraphQL Tools, so it will no longer get updates. Use GraphQL Tools instead to stay up-to-date! Check out https://www.graphql-tools.com/docs/migration-from-import for migration and https://the-guild.dev/blog/graphql-tools-v6 for new changes.

graphql-import
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

IMPORT_1

graphql-import

Discord Chat

Install

yarn add graphql-import

Usage

import { importSchema } from 'graphql-import'
import { makeExecutableSchema } from 'graphql-tools'
 
const typeDefs = importSchema('schema.graphql'); // or .gql or glob pattern like **/*.graphql
const resolvers = {};
 
const schema = makeExecutableSchema({ typeDefs, resolvers });
 

Assume the following directory structure:

.
├── schema.graphql
├── posts.graphql
└── comments.graphql

schema.graphql

# import Post from "posts.graphql"
 
type Query {
  posts: [Post]
}

posts.graphql

# import Comment from 'comments.graphql'
 
type Post {
  comments: [Comment]
  id: ID!
  text: String!
  tags: [String]
}

comments.graphql

type Comment {
  id: ID!
  text: String!
}

Running importSchema('schema.graphql') produces the following output:

type Query {
  posts: [Post]
}
 
type Post {
  comments: [Comment]
  id: ID!
  text: String!
  tags: [String]
}
 
type Comment {
  id: ID!
  text: String!
}

Readme

Keywords

none

Package Sidebar

Install

npm i graphql-import

Weekly Downloads

154,453

Version

1.0.2

License

MIT

Unpacked Size

13.9 kB

Total Files

16

Last publish

Collaborators

  • ardatan
  • dotansimha
  • kamilkisiela
  • kbrandwijk
  • schickling
  • timsuchanek
  • urigo