npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gtl-node

v0.0.3

Published

gtl-node multiple loader for graphql schema file

Downloads

12

Readme

Graphql Typedefs loader

Build Status Coverage Status codebeat badge CodeFactor Codacy Badge node-current npm npm bundle size npm bundle size Snyk Vulnerabilities for GitHub Repo PRs Welcome

Graphql Typedefs Loader is simple multiple loader schema for GraphQL, you can load many schema files with extension .graphql in your GraphQL project, please check more example usage, how about this module it works.

Installation

$ npm install gtl-node -S or yarn add gtl-node -S

Example Usage

  • Example Usage Multiple File Inside Directory
    • Example Usage Using CommonJs
      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
      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
      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
      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
      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
      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
      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
      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

    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

Bugs

For information on bugs related to package libraries, please visit here

Contributing

Want to make Graphql Typedefs Loader more perfect ? Let's contribute and follow the contribution guide.

License