JSPM

graphql-import

0.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 198248
  • Score
    100M100P100Q34737F
  • License MIT

Package Exports

  • graphql-import

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (graphql-import) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

graphql-import Build Status npm version Greenkeeper badge

Import & export definitions in GraphQL SDL (also refered to as GraphQL modules)

Install

yarn add graphql-import

Usage

import { importSchema } from 'graphql-import'
import { makeExecutableSchema } from 'graphql-tools'

const typeDefs = importSchema('schema.graphql')
const resolvers = {}

const schema = makeExecutableSchema({ typeDefs, resolvers })

Example

Assume the following directory structure:

.
├── a.graphql
├── b.graphql
└── c.graphql

a.graphql

# import B from "b.graphql"

type A {
  # test 1
  first: String @first
  second: Float
  b: B
}

b.graphql

# import C from 'c.graphql'

type B {
  c: C
  hello: String!
}

c.graphql

# import C from 'c.graphql'

type C {
  id: ID!
}

Running console.log(importSchema('a.graphql')) procudes the following output:

type A {
  first: String @first
  second: Float
  b: B
}

type B {
  c: C
  hello: String!
}

type C {
  id: ID!
}

Please refer to src/index.test.ts for more examples.

  • Namespaces
  • Support importing from HTTP endpoints (or Links)
  • Create RFC to add import syntax to GraphQL spec