graphql-import

[![Discord Chat](https://img.shields.io/discord/625400653321076807)](https://discord.gg/xud7bH9)

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.
Last updated 5 years ago by ardatan .
MIT · Repository · Original npm
$ cnpm install graphql-import 
SYNC missed versions from official npm registry.

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!
}

Current Tags

  • 1.0.3-8028e86.0                                ...           alpha (5 years ago)
  • 1.0.0-beta.1                                ...           beta (6 years ago)
  • 1.0.2                                ...           latest (5 years ago)

6 Versions

  • 0.4.5 [deprecated]           ...           8 years ago
  • 1.0.0 [deprecated]           ...           5 years ago
  • 1.0.2 [deprecated]           ...           5 years ago
  • 1.0.0-beta.1                                ...           6 years ago
  • 1.0.3-8028e86.0                                ...           5 years ago
  • 0.7.1 [deprecated]           ...           7 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dev Dependencies (10)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org