Graphql Typedefs Loader is simple multiple loader schema for GraphQL, you can load many schema files with extension .graphql or .gql
in your GraphQL project, please check more example usage or demo, how about this module it works.
$ npm install gtl-node -S or yarn add gtl-node -S
-
const http from = require('http') const { ApolloServer } = require('apollo-server-express') const { applyMiddleware } = require('graphql-middleware') const { makeExecutableSchema } = require('@graphql-tools/schema') const playground = require('graphql-playground-middleware-express') const express = require('express') // import module like this const { gtl } = require('gtl-node') // change with your graphql schema location folder const typeDefs = gtl({ directory: 'graphql/typeDefs', pattern: '**/*', extension: 'graphql' }) const { resolvers } = require('./graphql/resolvers') const graphqlPlayground = playground.default (async function () { const apolloServer = new ApolloServer({ schema: applyMiddleware(makeExecutableSchema({ typeDefs, resolvers })) }) const app = express() const server = http.createServer(app) app.get('/playground', graphqlPlayground({ endpoint: '/graphql', codeTheme: 'light' })) await apolloServer.start() apolloServer.applyMiddleware({ app }) server.listen(process.env.PORT || 3000, () => console.log(`Apollo server running on ${server.address().port}`)) })()
import http from 'http' import { ApolloServer } from 'apollo-server-express' import { applyMiddleware } from 'graphql-middleware' import { makeExecutableSchema } from '@graphql-tools/schema' import playground from 'graphql-playground-middleware-express' import express from 'express' // import module like this import { gtl } from 'gtl-node' // change with your graphql schema location folder const typeDefs = gtl({ directory: 'graphql/typeDefs', pattern: '**/*', extension: 'graphql' }) const { resolvers } = require('./graphql/resolvers') const graphqlPlayground = playground.default (async function () { const apolloServer = new ApolloServer({ schema: applyMiddleware(makeExecutableSchema({ typeDefs, resolvers })) }) const app = express() const server = http.createServer(app) app.get('/playground', graphqlPlayground({ endpoint: '/graphql', codeTheme: 'light' })) await apolloServer.start() apolloServer.applyMiddleware({ app }) server.listen(process.env.PORT || 3000, () => console.log(`Apollo server running on ${server.address().port}`)) })()
-
const http from = require('http') const { ApolloServer } = require('apollo-server-express') const { applyMiddleware } = require('graphql-middleware') const { makeExecutableSchema } = require('@graphql-tools/schema') const playground = require('graphql-playground-middleware-express') const express = require('express') // import module like this const { gtl } = require('gtl-node') // change with your graphql schema location folder const typeDefs = gtl({ pattern: '**/*', extension: 'graphql' }) const { resolvers } = require('./graphql/resolvers') const graphqlPlayground = playground.default (async function () { const apolloServer = new ApolloServer({ schema: applyMiddleware(makeExecutableSchema({ typeDefs, resolvers })) }) const app = express() const server = http.createServer(app) app.get('/playground', graphqlPlayground({ endpoint: '/graphql', codeTheme: 'light' })) await apolloServer.start() apolloServer.applyMiddleware({ app }) server.listen(process.env.PORT || 3000, () => console.log(`Apollo server running on ${server.address().port}`)) })()
import http from 'http' import { ApolloServer } from 'apollo-server-express' import { applyMiddleware } from 'graphql-middleware' import { makeExecutableSchema } from '@graphql-tools/schema' import playground from 'graphql-playground-middleware-express' import express from 'express' // import module like this import { gtl } from 'gtl-node' // change with your graphql schema location folder const typeDefs = gtl({ pattern: '**/*', extension: 'graphql' }) const { resolvers } = require('./graphql/resolvers') const graphqlPlayground = playground.default (async function () { const apolloServer = new ApolloServer({ schema: applyMiddleware(makeExecutableSchema({ typeDefs, resolvers })) }) const app = express() const server = http.createServer(app) app.get('/playground', graphqlPlayground({ endpoint: '/graphql', codeTheme: 'light' })) await apolloServer.start() apolloServer.applyMiddleware({ app }) server.listen(process.env.PORT || 3000, () => console.log(`Apollo server running on ${server.address().port}`)) })()
-
const http from = require('http') const { ApolloServer } = require('apollo-server-express') const { applyMiddleware } = require('graphql-middleware') const { makeExecutableSchema } = require('@graphql-tools/schema') const playground = require('graphql-playground-middleware-express') const express = require('express') // import module like this const { gtl } = require('gtl-node') // change with your graphql schema location folder const typeDefs = gtl({ directory: 'graphql/typedefs' , fileName: 'schema.graphql' }) const { resolvers } = require('./graphql/resolvers') const graphqlPlayground = playground.default (async function () { const apolloServer = new ApolloServer({ schema: applyMiddleware(makeExecutableSchema({ typeDefs, resolvers })) }) const app = express() const server = http.createServer(app) app.get('/playground', graphqlPlayground({ endpoint: '/graphql', codeTheme: 'light' })) await apolloServer.start() apolloServer.applyMiddleware({ app }) server.listen(process.env.PORT || 3000, () => console.log(`Apollo server running on ${server.address().port}`)) })()
import http from 'http' import { ApolloServer } from 'apollo-server-express' import { applyMiddleware } from 'graphql-middleware' import { makeExecutableSchema } from '@graphql-tools/schema' import playground from 'graphql-playground-middleware-express' import express from 'express' // import module like this import { gtl } from 'gtl-node' // change with your graphql schema location folder const typeDefs = gtl({ directory: 'graphql/typedefs' , fileName: 'schema.graphql' }) const { resolvers } = require('./graphql/resolvers') const graphqlPlayground = playground.default (async function () { const apolloServer = new ApolloServer({ schema: applyMiddleware(makeExecutableSchema({ typeDefs, resolvers })) }) const app = express() const server = http.createServer(app) app.get('/playground', graphqlPlayground({ endpoint: '/graphql', codeTheme: 'light' })) await apolloServer.start() apolloServer.applyMiddleware({ app }) server.listen(process.env.PORT || 3000, () => console.log(`Apollo server running on ${server.address().port}`)) })()
-
const http from = require('http') const { ApolloServer } = require('apollo-server-express') const { applyMiddleware } = require('graphql-middleware') const { makeExecutableSchema } = require('@graphql-tools/schema') const playground = require('graphql-playground-middleware-express') const express = require('express') // import module like this const { gtl } = require('gtl-node') // change with your graphql schema location folder const typeDefs = gtl({ fileName: 'schema.graphql' }) const { resolvers } = require('./graphql/resolvers') const graphqlPlayground = playground.default (async function () { const apolloServer = new ApolloServer({ schema: applyMiddleware(makeExecutableSchema({ typeDefs, resolvers })) }) const app = express() const server = http.createServer(app) app.get('/playground', graphqlPlayground({ endpoint: '/graphql', codeTheme: 'light' })) await apolloServer.start() apolloServer.applyMiddleware({ app }) server.listen(process.env.PORT || 3000, () => console.log(`Apollo server running on ${server.address().port}`)) })()
import http from 'http' import { ApolloServer } from 'apollo-server-express' import { applyMiddleware } from 'graphql-middleware' import { makeExecutableSchema } from '@graphql-tools/schema' import playground from 'graphql-playground-middleware-express' import express from 'express' // import module like this import { gtl } from 'gtl-node' // change with your graphql schema location folder const typeDefs = gtl({ fileName: 'schema.graphql' }) const { resolvers } = require('./graphql/resolvers') const graphqlPlayground = playground.default (async function () { const apolloServer = new ApolloServer({ schema: applyMiddleware(makeExecutableSchema({ typeDefs, resolvers })) }) const app = express() const server = http.createServer(app) app.get('/playground', graphqlPlayground({ endpoint: '/graphql', codeTheme: 'light' })) await apolloServer.start() apolloServer.applyMiddleware({ app }) server.listen(process.env.PORT || 3000, () => console.log(`Apollo server running on ${server.address().port}`)) })()
-
Testing Via Local
npm test or make test
-
Testing Via Local And Build
make build
-
Testing Via Docker
docker build -t gtl-node or make dkb tag=gtl-node
For information on bugs related to package libraries, please visit here
Want to make Graphql Typedefs Loader more perfect ? Let's contribute and follow the contribution guide.