All Projects → wittydeveloper → Graphql To Json Schema

wittydeveloper / Graphql To Json Schema

Licence: mit
GraphQL Schema to JSON Schema

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Graphql To Json Schema

Jsonschema2graphql
Convert JSON schema to GraphQL types
Stars: ✭ 24 (-72.41%)
Mutual labels:  graphql, json-schema
Quicktype
Generate types and converters from JSON, Schema, and GraphQL
Stars: ✭ 7,459 (+8473.56%)
Mutual labels:  graphql, json-schema
Rxdb
🔄 A client side, offline-first, reactive database for JavaScript Applications
Stars: ✭ 16,670 (+19060.92%)
Mutual labels:  graphql, json-schema
Rest Layer
REST Layer, Go (golang) REST API framework
Stars: ✭ 1,068 (+1127.59%)
Mutual labels:  graphql, json-schema
Accounts
Fullstack authentication and accounts-management for Javascript.
Stars: ✭ 1,266 (+1355.17%)
Mutual labels:  graphql
Python Lambdarest
Flask like web framework for AWS Lambda
Stars: ✭ 84 (-3.45%)
Mutual labels:  json-schema
Graphql Transform Schema
Transform, filter & alias resolvers of a GraphQL schema
Stars: ✭ 84 (-3.45%)
Mutual labels:  graphql
Projectartemis
An analytic tool for GraphQL queries to external APIs with a Graphical User Interface to view performance metrics.
Stars: ✭ 84 (-3.45%)
Mutual labels:  graphql
Mayoor
Modern Order Management System - fullstack app built using Typescript, GraphQL, React, Prisma2
Stars: ✭ 87 (+0%)
Mutual labels:  graphql
Review Waiting List Bot
Make your team's review great again! ✨ It's a Slack bot to list up review waiting list.
Stars: ✭ 86 (-1.15%)
Mutual labels:  graphql
Hostyhosting
A platform to easily manage and deploy your applications.
Stars: ✭ 86 (-1.15%)
Mutual labels:  graphql
Sapper Typescript Graphql Template
A template that includes Sapper for Svelte, TypeScript preprocessing, and a GraphQL server through TypeGraphQL
Stars: ✭ 84 (-3.45%)
Mutual labels:  graphql
Understanding Json Schema
A website aiming to provide more accessible documentation for JSON schema.
Stars: ✭ 1,268 (+1357.47%)
Mutual labels:  json-schema
Graphql Example
An example code structure for a GraphQL-powered mobile app. Contains client and server code.
Stars: ✭ 83 (-4.6%)
Mutual labels:  graphql
Dgraphql
DgraphQL: Build a GraphQL service from a schema
Stars: ✭ 86 (-1.15%)
Mutual labels:  graphql
Graphql Import Loader
Webpack loader for `graphql-import`
Stars: ✭ 84 (-3.45%)
Mutual labels:  graphql
Graphjin
GraphJin - Build APIs in 5 minutes with GraphQL. An instant GraphQL to SQL compiler.
Stars: ✭ 1,264 (+1352.87%)
Mutual labels:  graphql
React Dashboard
🔥React Dashboard - isomorphic admin dashboard template (React.js, Bootstrap, Node.js, GraphQL, React Router, Babel, Webpack, Browsersync) 🔥
Stars: ✭ 1,268 (+1357.47%)
Mutual labels:  graphql
Preact Redux Isomorphic
preact-redux-isomorphic PWA SPA SSR best practices and libraries in under 80kB page size (for live demo click the link below)
Stars: ✭ 85 (-2.3%)
Mutual labels:  graphql
Boilerplate Vue Apollo Graphql Mongodb
Start your magical stack journey!
Stars: ✭ 85 (-2.3%)
Mutual labels:  graphql

GraphQL Schema to JSON Schema npm version

graphql-2-json-schema package


Transform a GraphQL Schema introspection file to a valid JSON Schema.

Usage

import {
    graphqlSync,
    getIntrospectionQuery,
    IntrospectionQuery
} from 'graphql';

import { fromIntrospectionQuery } from 'graphql-2-json-schema';

const options = {
  // Whether or not to ignore GraphQL internals that are probably not relevant
  // to documentation generation.
  // Defaults to `true`
  ignoreInternals: true,
  // Whether or not to properly represent GraphQL Lists with Nullable elements
  // as type "array" with items being an "anyOf" that includes the possible
  // type and a "null" type.
  // Defaults to `false` for backwards compatibility, but in future versions
  // the effect of `true` is likely going to be the default and only way. It is
  // highly recommended that new implementations set this value to `true`.
  nullableArrayItems: true
}

// schema is your GraphQL schema.
const introspection = graphqlSync(schema, getIntrospectionQuery()).data as IntrospectionQuery;

const jsonSchema = fromIntrospectionQuery(introspection, options);

Example

Input

  type Todo {
      id: String!
      name: String!
      completed: Boolean
      color: Color

      "A field that requires an argument"
      colors(
        filter: [Color!]!
      ): [Color!]!
  }

  input TodoInputType {
      name: String!
      completed: Boolean
      color: Color=RED
  }

  enum Color {
      "Red color"
      RED
      "Green color"
      GREEN
  }

  type Query {
      "A Query with 1 required argument and 1 optional argument"
      todo(
        id: String!,
        "A default value of false"
        isCompleted: Boolean=false
      ): Todo

      "Returns a list (or null) that can contain null values"
      todos(
        "Reauired argument that is a list that cannot contain null values"
        ids: [String!]!
      ): [Todo]
  }

  type Mutation {
      "A Mutation with 1 required argument"
      create_todo(
        todo: TodoInputType!
      ): Todo!

      "A Mutation with 2 required arguments"
      update_todo(
        id: String!,
        data: TodoInputType!
      ): Todo!

      "Returns a list (or null) that can contain null values"
      update_todos(
        ids: [String!]!
        data: TodoInputType!
      ): [Todo]
  }

Output

// Output is from call to fromIntrospectionQuery with the following options:
const options = { nullableArrayItems: true }

{
  '$schema': 'http://json-schema.org/draft-06/schema#',
  properties: {
    Query: {
      type: 'object',
      properties: {
        todo: {
          description: 'A Query with 1 required argument and 1 optional argument',
          type: 'object',
          properties: {
            return: { '$ref': '#/definitions/Todo' },
            arguments: {
              type: 'object',
              properties: {
                id: { '$ref': '#/definitions/String' },
                isCompleted: {
                  description: 'A default value of false',
                  '$ref': '#/definitions/Boolean',
                  default: false
                }
              },
              required: [ 'id' ]
            }
          },
          required: []
        },
        todos: {
          description: 'Returns a list (or null) that can contain null values',
          type: 'object',
          properties: {
            return: {
              type: 'array',
              items: {
                anyOf: [ { '$ref': '#/definitions/Todo' }, { type: 'null' } ]
              }
            },
            arguments: {
              type: 'object',
              properties: {
                ids: {
                  description: 'Reauired argument that is a list that cannot contain null values',
                  type: 'array',
                  items: { '$ref': '#/definitions/String' }
                }
              },
              required: [ 'ids' ]
            }
          },
          required: []
        }
      },
      required: []
    },
    Mutation: {
      type: 'object',
      properties: {
        create_todo: {
          description: 'A Mutation with 1 required argument',
          type: 'object',
          properties: {
            return: { '$ref': '#/definitions/Todo' },
            arguments: {
              type: 'object',
              properties: { todo: { '$ref': '#/definitions/TodoInputType' } },
              required: [ 'todo' ]
            }
          },
          required: []
        },
        update_todo: {
          description: 'A Mutation with 2 required arguments',
          type: 'object',
          properties: {
            return: { '$ref': '#/definitions/Todo' },
            arguments: {
              type: 'object',
              properties: {
                id: { '$ref': '#/definitions/String' },
                data: { '$ref': '#/definitions/TodoInputType' }
              },
              required: [ 'id', 'data' ]
            }
          },
          required: []
        },
        update_todos: {
          description: 'Returns a list (or null) that can contain null values',
          type: 'object',
          properties: {
            return: {
              type: 'array',
              items: {
                anyOf: [ { '$ref': '#/definitions/Todo' }, { type: 'null' } ]
              }
            },
            arguments: {
              type: 'object',
              properties: {
                ids: {
                  type: 'array',
                  items: { '$ref': '#/definitions/String' }
                },
                data: { '$ref': '#/definitions/TodoInputType' }
              },
              required: [ 'ids', 'data' ]
            }
          },
          required: []
        }
      },
      required: []
    }
  },
  definitions: {
    Todo: {
      type: 'object',
      properties: {
        id: {
          type: 'object',
          properties: {
            return: { '$ref': '#/definitions/String' },
            arguments: { type: 'object', properties: {}, required: [] }
          },
          required: []
        },
        name: {
          type: 'object',
          properties: {
            return: { '$ref': '#/definitions/String' },
            arguments: { type: 'object', properties: {}, required: [] }
          },
          required: []
        },
        completed: {
          type: 'object',
          properties: {
            return: { '$ref': '#/definitions/Boolean' },
            arguments: { type: 'object', properties: {}, required: [] }
          },
          required: []
        },
        color: {
          type: 'object',
          properties: {
            return: { '$ref': '#/definitions/Color' },
            arguments: { type: 'object', properties: {}, required: [] }
          },
          required: []
        },
        colors: {
          description: 'A field that requires an argument',
          type: 'object',
          properties: {
            return: { type: 'array', items: { '$ref': '#/definitions/Color' } },
            arguments: {
              type: 'object',
              properties: {
                filter: {
                  type: 'array',
                  items: { '$ref': '#/definitions/Color' }
                }
              },
              required: [ 'filter' ]
            }
          },
          required: []
        }
      },
      required: [ 'id', 'name', 'colors' ]
    },
    TodoInputType: {
      type: 'object',
      properties: {
        name: { '$ref': '#/definitions/String' },
        completed: { '$ref': '#/definitions/Boolean' },
        color: { '$ref': '#/definitions/Color', default: 'RED' }
      },
      required: [ 'name' ]
    },
    Color: {
      type: 'string',
      anyOf: [
        {
          description: 'Red color',
          enum: [ 'RED' ],
          title: 'Red color'
        },
        {
          description: 'Green color',
          enum: [ 'GREEN' ],
          title: 'Green color'
        }
      ]
    },
    String: {
      description: 'The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.',
      type: 'string',
      title: 'String'
    },
    Boolean: {
      description: 'The `Boolean` scalar type represents `true` or `false`.',
      type: 'boolean',
      title: 'Boolean'
    }
  }
}
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].