All Projects → ardatan → Graphql Tools

ardatan / Graphql Tools

Licence: mit
🔧 Build, mock, and stitch a GraphQL schema using the schema language

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Graphql Tools

Typegql
Create GraphQL schema with TypeScript classes.
Stars: ✭ 415 (-90.89%)
Mutual labels:  graphql, graphql-api, graphql-js, graphql-schema
Graphql2rest
GraphQL to REST converter: automatically generate a RESTful API from your existing GraphQL API
Stars: ✭ 181 (-96.03%)
Mutual labels:  graphql, graphql-api, graphql-js, graphql-schema
graphql-express-nodejs
A Simple GraphQL Server implementation using Express and Node. See post here: https://t.co/Cm6GitZaBL
Stars: ✭ 24 (-99.47%)
Mutual labels:  graphql-schema, graphql-js, graphql-api
Graphql Cost Analysis
A Graphql query cost analyzer.
Stars: ✭ 527 (-88.43%)
Mutual labels:  graphql, graphql-js, graphql-schema
Graphql Log
Add logging to your GraphQL resolvers so you know what's going on in your app.
Stars: ✭ 94 (-97.94%)
Mutual labels:  graphql, graphql-js, graphql-schema
Postgraphile
GraphQL is a new way of communicating with your server. It eliminates the problems of over- and under-fetching, incorporates strong data types, has built-in introspection, documentation and deprecation capabilities, and is implemented in many programming languages. This all leads to gloriously low-latency user experiences, better developer experiences, and much increased productivity. Because of all this, GraphQL is typically used as a replacement for (or companion to) RESTful API services.
Stars: ✭ 10,967 (+140.72%)
Mutual labels:  graphql, graphql-api, graphql-js
Type Graphql
Create GraphQL schema and resolvers with TypeScript, using classes and decorators!
Stars: ✭ 6,864 (+50.66%)
Mutual labels:  graphql, graphql-js, graphql-schema
Hangzhou Graphql Party
杭州 GraphQLParty 往期记录(slide,照片,预告,视频等)
Stars: ✭ 142 (-96.88%)
Mutual labels:  graphql, graphql-api, graphql-js
Hotchocolate
Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
Stars: ✭ 3,009 (-33.96%)
Mutual labels:  graphql, graphql-schema, schema-stitching
Grial
A Node.js framework for creating GraphQL API servers easily and without a lot of boilerplate.
Stars: ✭ 194 (-95.74%)
Mutual labels:  graphql, graphql-api, graphql-js
36 Graphql Concepts
📜 36 concepts every GraphQL developer should know.
Stars: ✭ 209 (-95.41%)
Mutual labels:  graphql, graphql-api, graphql-schema
graphql-spotify
GraphQL Schema And Resolvers For Spotify Web API
Stars: ✭ 55 (-98.79%)
Mutual labels:  graphql-schema, graphql-js
graphql-api
GraphQL-Api is an opinionated Graphql framework for Rails that supports auto generating queries based on Active Record models and plain Ruby objects
Stars: ✭ 58 (-98.73%)
Mutual labels:  graphql-schema, graphql-api
Easygraphql Tester
Test GraphQL queries, mutations and schemas on an easy way! 🚀
Stars: ✭ 242 (-94.69%)
Mutual labels:  graphql, graphql-schema
relay-compiler-plus
Custom relay compiler which supports persisted queries
Stars: ✭ 68 (-98.51%)
Mutual labels:  graphql-schema, graphql-js
graphql-binding-yelp
Embed Yelp's GraphQL API into your server application
Stars: ✭ 11 (-99.76%)
Mutual labels:  graphql-schema, schema-stitching
Graphql To Mongodb
Allows for generic run-time generation of filter types for existing graphql types and parsing client requests to mongodb find queries
Stars: ✭ 261 (-94.27%)
Mutual labels:  graphql, graphql-js
Morpheus Graphql
Haskell GraphQL Api, Client and Tools
Stars: ✭ 285 (-93.74%)
Mutual labels:  graphql, graphql-api
Graphql Js
A reference implementation of GraphQL for JavaScript
Stars: ✭ 18,251 (+300.59%)
Mutual labels:  graphql, graphql-js
Graphqlize
A Clojure & JVM library for developing GraphQL API instantly from Postgres and MySQL databases
Stars: ✭ 240 (-94.73%)
Mutual labels:  graphql, graphql-api

toolkit

npm version CI Discord Chat code style: prettier renovate-app badge

This package provides a few useful ways to create a GraphQL schema:

  1. Use the GraphQL schema language to generate a schema with full support for resolvers, interfaces, unions, and custom scalars. The schema produced is completely compatible with GraphQL.js.
  2. Mock your GraphQL API with fine-grained per-type mocking
  3. Automatically stitch multiple schemas together into one larger API

Documentation

Read the docs.

Binding to HTTP

If you want to bind your JavaScript GraphQL schema to an HTTP server, you can use express-graphql .

You can develop your JavaScript based GraphQL API with graphql-tools and express-graphql together: One to write the schema and resolver code, and the other to connect it to a web server.

Example

When using graphql-tools, you describe the schema as a GraphQL type language string:

const typeDefs = /* GraphQL */ `
  type Author {
    id: ID! # the ! means that every author object _must_ have an id
    firstName: String
    lastName: String
    """
    the list of Posts by this author
    """
    posts: [Post]
  }

  type Post {
    id: ID!
    title: String
    author: Author
    votes: Int
  }

  # the schema allows the following query:
  type Query {
    posts: [Post]
  }

  # this schema allows the following mutation:
  type Mutation {
    upvotePost(postId: ID!): Post
  }

  # we need to tell the server which types represent the root query
  # and root mutation types. We call them RootQuery and RootMutation by convention.
  schema {
    query: Query
    mutation: Mutation
  }
`

export default typeDefs

Then you define resolvers as a nested object that maps type and field names to resolver functions:

const resolvers = {
  Query: {
    posts() {
      return posts
    }
  },
  Mutation: {
    upvotePost(_, { postId }) {
      const post = find(posts, { id: postId })
      if (!post) {
        throw new Error(`Couldn't find post with id ${postId}`)
      }
      post.votes += 1
      return post
    }
  },
  Author: {
    posts(author) {
      return filter(posts, { authorId: author.id })
    }
  },
  Post: {
    author(post) {
      return find(authors, { id: post.authorId })
    }
  }
}

export default resolvers

At the end, the schema and resolvers are combined using makeExecutableSchema:

import { makeExecutableSchema } from '@graphql-tools/schema'

const executableSchema = makeExecutableSchema({
  typeDefs,
  resolvers
})

GraphQL-Tools schema can be consumed by frameworks like Apollo GraphQL or express-graphql For example

const express = require('express')
const { graphqlHTTP } = require('express-graphql')

const app = express()
app.use(
  '/graphql',
  graphqlHTTP({
    schema: executableSchema,
    graphiql: true
  })
)
app.listen(4000)
console.log('Running a GraphQL API server at http://localhost:4000/graphql')

This example has the entire type definition in one string and all resolvers in one file, but you can combine types and resolvers from multiple files and objects, as documented in the modularizing type definitions and merging resolvers section of the docs.

Contributions

Contributions, issues and feature requests are very welcome. If you are using this package and fixed a bug for yourself, please consider submitting a PR!

And if this is your first time contributing to this project, please do read our Contributor Workflow Guide before you get started off.

Code of Conduct

Help us keep GraphQL Tools open and inclusive. Please read and follow our Code of Conduct as adopted from Contributor Covenant

Maintainers

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].