@mihaiblaga89/appsync-graphql-import
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

graphql-import

npm version

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

Forked from https://github.com/ardatan/graphql-import since that seems to not be maintained anymore and I needed a way for AppSync's GQL tags to work with this

Features

  1. same as https://github.com/ardatan/graphql-import
  2. added support for @searchable, @model and @aws_auth

Install

yarn add @mihaiblaga89/appsync-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 })

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 console.log(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 @mihaiblaga89/appsync-graphql-import

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

59 kB

Total Files

12

Last publish

Collaborators

  • mihaiblaga89