node-graphql-import
v1.1.0
Published
imports .graphql or .gql files from path
Downloads
11
Readme
node-graphql-import
Installation
npm install --save react-testing-library
yarn add react-testing-library
Details
imports .graphql or .gql files from folder and convert them into graphql tag.
Options
filesPath - path to folder
fileTag - part of filename // only files containing the fileTag in the name will be imported (.ie fileTag TYPE imports only UserTYPE.graphql, PostTYPE.graphql etc, PostENUM.graphql will not be imported )
Example
example file structure
|root
--|schema
--Mutation.graphql
--Query.graphql
----|type
--UserTYPE.graphql
----|input
--UserINPUT.graphql
----|enum
--UserStatusENUM.graphql
----|custom
--UserCUSTOM.graphql
import path from "path";
import SchemaRequire from "node-graphql-import";
import { ApolloServer } from "apollo-server-express";
const RootSchema = SchemaRequire({ filesPath: path.join(__dirname,"./schema") });
const TypeSchema = SchemaRequire({ filesPath: path.join(__dirname,"./schema/type") });
const InputSchema = SchemaRequire({ filesPath: path.join(__dirname,"./schema/input") });
const EnumSchema = SchemaRequire({ filesPath: path.join(__dirname,"./schema/enum") });
const CustomSchema = SchemaRequire({ filesPath: path.join(__dirname,"./schema/custom"), "CUSTOM"});
const server = new ApolloServer({
typeDefs: [RootSchema, TypeSchema,InputSchema, EnumSchema],
resolvers,
});