# graphql-import

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

Latest version **1.0.2** (published 2020-04-08) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install graphql-import
pnpm add graphql-import
yarn add graphql-import
bun add graphql-import
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-04-08 |
| First published | 2017-11-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Unpacked size | 13.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 864 |
| Maintainers | ardatan, dotansimha, kamilkisiela, kbrandwijk, schickling, timsuchanek, urigo |

## Links

- npm: https://www.npmjs.com/package/graphql-import
- Repository: git@github.com:ardatan/graphql-import
- npm.io page: https://npm.io/package/graphql-import

## Dependencies (6)

- [@graphql-toolkit/core](https://npm.io/package/@graphql-toolkit/core.md) 0.10.3
- [@graphql-toolkit/url-loader](https://npm.io/package/@graphql-toolkit/url-loader.md) 0.10.3
- [@graphql-toolkit/schema-merging](https://npm.io/package/@graphql-toolkit/schema-merging.md) 0.10.3
- [@graphql-toolkit/code-file-loader](https://npm.io/package/@graphql-toolkit/code-file-loader.md) 0.10.3
- [@graphql-toolkit/json-file-loader](https://npm.io/package/@graphql-toolkit/json-file-loader.md) 0.10.3
- [@graphql-toolkit/graphql-file-loader](https://npm.io/package/@graphql-toolkit/graphql-file-loader.md) 0.10.3

## Recent versions

- 1.0.2 (latest) — 2020-04-08
- 1.0.3-8028e86.0 (alpha) — 2020-05-21
- 1.0.0-beta.1 (beta) — 2020-01-06
- 1.0.3-82ae1bc.0 — 2020-05-21
- 1.0.3-70b0a73.0 — 2020-05-21
- 1.0.3-599b11d.0 — 2020-05-20
- 1.0.3-c71a5a9.0 — 2020-05-20
- 1.0.3-215748a.0 — 2020-05-20
- 1.0.3-b550dc8.0 — 2020-05-19
- 1.0.3-57f4935.0 — 2020-05-19
- 1.0.3-ee3193d.0 — 2020-05-19
- 1.0.3-7e74003.0 — 2020-05-19
- 1.0.3-cfdfa04.0 — 2020-05-19
- 1.0.3-ad7dfe0.0 — 2020-05-18
- 1.0.3-47dba75.0 — 2020-05-18
- … 416 more at https://npm.io/package/graphql-import/versions

## README

![IMPORT_1](https://user-images.githubusercontent.com/25294569/76310705-fc621b00-62d7-11ea-9643-1670cfe6be18.gif)
# graphql-import

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

## Install

```sh
yarn add graphql-import
```

## Usage

```ts
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`

```graphql
# import Post from "posts.graphql"

type Query {
  posts: [Post]
}
```

`posts.graphql`

```graphql
# import Comment from 'comments.graphql'

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

`comments.graphql`

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

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

```graphql
type Query {
  posts: [Post]
}

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

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

---
_Source: https://npm.io/package/graphql-import · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
