graphql-import
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -46,2 +46,6 @@ "use strict"; | ||
}); | ||
ava_1.default('importSchema: import all', function (t) { | ||
var expectedSDL = "type A {\n first: String @first\n second: Float\n b: B\n}\n\ntype B {\n hello: String!\n}\n\ntype C1 {\n id: ID!\n}\n\ntype C2 {\n id: ID!\n}\n"; | ||
t.is(_1.importSchema('fixtures/import-all/a.graphql'), expectedSDL); | ||
}); | ||
ava_1.default('importSchema: interfaces', function (t) { | ||
@@ -48,0 +52,0 @@ var expectedSDL = "type A implements B {\n first: String @first\n second: Float\n}\n\ninterface B {\n second: Float\n}\n"; |
{ | ||
"name": "graphql-import", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"license": "MIT", | ||
"files": ["dist"], | ||
"repository": "git@github.com:graphcool/graphql-import.git", | ||
"files": [ | ||
"dist" | ||
], | ||
"main": "dist/index.js", | ||
@@ -13,3 +16,3 @@ "typings": "dist/index.d.ts", | ||
"prepublish": "npm run build", | ||
"build": "rm -rf dist && tsc", | ||
"build": "rm -rf dist && tsc -d", | ||
"test-only": "npm run build && ava --verbose dist/**/*.test.js", | ||
@@ -16,0 +19,0 @@ "test": "tslint src/**/*.ts && npm run test-only" |
@@ -1,2 +0,93 @@ | ||
# graphql-modules | ||
Import & export definitions in GraphQL SDL | ||
# graphql-import [![Build Status](https://travis-ci.org/graphcool/graphql-import.svg?branch=master)](https://travis-ci.org/graphcool/graphql-import) [![npm version](https://badge.fury.io/js/graphql-import.svg)](https://badge.fury.io/js/graphql-import) [![Greenkeeper badge](https://badges.greenkeeper.io/graphcool/graphql-import.svg)](https://greenkeeper.io/) | ||
Import & export definitions in GraphQL SDL (also refered to as GraphQL modules) | ||
## Install | ||
```sh | ||
yarn add graphql-import | ||
``` | ||
## Usage | ||
```ts | ||
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` | ||
```graphql | ||
# import B from "b.graphql" | ||
type A { | ||
# test 1 | ||
first: String @first | ||
second: Float | ||
b: B | ||
} | ||
``` | ||
`b.graphql` | ||
```graphql | ||
# import C from 'c.graphql' | ||
type B { | ||
c: C | ||
hello: String! | ||
} | ||
``` | ||
`c.graphql` | ||
```graphql | ||
# import C from 'c.graphql' | ||
type C { | ||
id: ID! | ||
} | ||
``` | ||
Running `console.log(importSchema('a.graphql'))` procudes the following output: | ||
```graphql | ||
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`](src/index.test.ts) for more examples. | ||
## Related topics & next steps | ||
- Namespaces | ||
- Support importing from HTTP endpoints (or [Links](https://github.com/apollographql/apollo-link)) | ||
- Create RFC to add import syntax to GraphQL spec |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
22189
12
226
93
155192