Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/restuwahyu13/graphql-typedefs-loader
Multiple loader for graphql schema file
https://github.com/restuwahyu13/graphql-typedefs-loader
graphql graphql-tools graphql-typedefs-loader gtl-node javascript loader node-module nodejs typedefs typescript
Last synced: 11 days ago
JSON representation
Multiple loader for graphql schema file
- Host: GitHub
- URL: https://github.com/restuwahyu13/graphql-typedefs-loader
- Owner: restuwahyu13
- License: mit
- Created: 2021-07-17T11:08:21.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-30T12:04:57.000Z (almost 2 years ago)
- Last Synced: 2024-04-25T22:43:19.490Z (7 months ago)
- Topics: graphql, graphql-tools, graphql-typedefs-loader, gtl-node, javascript, loader, node-module, nodejs, typedefs, typescript
- Language: TypeScript
- Homepage:
- Size: 504 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Graphql Typedefs loader
[![Build Status](https://travis-ci.com/restuwahyu13/graphql-typedefs-loader.svg?branch=main)](https://travis-ci.com/restuwahyu13/graphql-typedefs-loader) [![Coverage Status](https://coveralls.io/repos/github/restuwahyu13/graphql-typedefs-loader/badge.svg?branch=main)](https://coveralls.io/github/restuwahyu13/graphql-typedefs-loader?branch=main) [![codebeat badge](https://codebeat.co/badges/857cbfb1-53a4-41e5-a9a0-38152987a7d4)](https://codebeat.co/projects/github-com-restuwahyu13-graphql-typedefs-loader-main) [![CodeFactor](https://www.codefactor.io/repository/github/restuwahyu13/graphql-typedefs-loader/badge)](https://www.codefactor.io/repository/github/restuwahyu13/graphql-typedefs-loader) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/d368f0998e7641c4a85a796e7dae3f6a)](https://www.codacy.com/gh/restuwahyu13/graphql-typedefs-loader/dashboard?utm_source=github.com&utm_medium=referral&utm_content=restuwahyu13/graphql-typedefs-loader&utm_campaign=Badge_Grade) ![node-current](https://img.shields.io/node/v/gtl-node?style=flat-square) ![npm](https://img.shields.io/npm/dm/gtl-node) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/restuwahyu13/graphql-typedefs-loader/blob/main/CONTRIBUTING.md)
**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.
- [Installation](#installation)
- [Example Usage](#example-usage)
- [Testing](#testing)
- [Bugs](#bugs)
- [Contributing](#contributing)
- [License](#license)## Installation
```bash
$ npm install gtl-node -S or yarn add gtl-node -S
```## Example Usage
+ ##### Example Usage Multiple File Inside Directory
- ##### Example Usage Using CommonJs
```javascript
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}`))
})()
```- ##### Example Usage Using ES6
```javascript
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}`))
})()
```
+ ##### Example Usage Multiple File Outside Directory- ##### Example Usage Using CommonJs
```javascript
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}`))
})()
```- ##### Example Usage Using ES6
```javascript
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}`))
})()
```+ ##### Example Usage Single File Inside Directory
- ##### Example Usage Using CommonJs
```javascript
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}`))
})()
```- ##### Example Usage Using ES6
```javascript
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}`))
})()
```+ ##### Example Usage Single File Outside Directory
- ##### Example Usage Using CommonJs
```javascript
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}`))
})()
```- ##### Example Usage Using ES6
```javascript
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
- Testing Via Local
```sh
npm test or make test
```- Testing Via Local And Build
```sh
make build
```- Testing Via Docker
```sh
docker build -t gtl-node or make dkb tag=gtl-node
```### Bugs
For information on bugs related to package libraries, please visit [here](https://github.com/restuwahyu13/graphql-typedefs-loader/issues)
### Contributing
Want to make **Graphql Typedefs Loader** more perfect ? Let's contribute and follow the [contribution guide.](https://github.com/restuwahyu13/graphql-typedefs-loader/blob/main/CONTRIBUTING.md)
### License
- [MIT License](https://github.com/restuwahyu13/graphql-typedefs-loader/blob/main/LICENSE.md)