All Projects → graphql-factory → Graphql Factory

graphql-factory / Graphql Factory

Licence: mit
A toolkit for building GraphQL

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Graphql Factory

Framework
Strongly-typed JavaScript object with support for validation and error handling.
Stars: ✭ 136 (+209.09%)
Mutual labels:  graphql, json, schema
Prettier
Prettier is an opinionated code formatter.
Stars: ✭ 41,411 (+94015.91%)
Mutual labels:  graphql, ast, json
Quicktype
Generate types and converters from JSON, Schema, and GraphQL
Stars: ✭ 7,459 (+16852.27%)
Mutual labels:  graphql, json
Graphql Code Generator
A tool for generating code based on a GraphQL schema and GraphQL operations (query/mutation/subscription), with flexible support for custom plugins.
Stars: ✭ 7,993 (+18065.91%)
Mutual labels:  graphql, schema
Rdbms To Graphql
A Java CLI program that generates a GraphQL schema from a JDBC data source.
Stars: ✭ 44 (+0%)
Mutual labels:  graphql, schema
Stash
An organizer for your porn, written in Go
Stars: ✭ 591 (+1243.18%)
Mutual labels:  graphql, json
Coolqlcool
Nextjs server to query websites with GraphQL
Stars: ✭ 623 (+1315.91%)
Mutual labels:  graphql, schema
Angular Builders
Angular build facade extensions (Jest and custom webpack configuration)
Stars: ✭ 843 (+1815.91%)
Mutual labels:  build, custom
Plank
A tool for generating immutable model objects
Stars: ✭ 449 (+920.45%)
Mutual labels:  json, schema
Apicache
Simple API-caching middleware for Express/Node.
Stars: ✭ 957 (+2075%)
Mutual labels:  middleware, json
Graphql Compose
Toolkit for generating complex GraphQL Schemas on Node.js
Stars: ✭ 947 (+2052.27%)
Mutual labels:  graphql, schema
Graphql Upload
Middleware and an Upload scalar to add support for GraphQL multipart requests (file uploads via queries and mutations) to various GoLang GraphQL servers
Stars: ✭ 32 (-27.27%)
Mutual labels:  graphql, middleware
Tuql
Automatically create a GraphQL server from a SQLite database or a SQL file
Stars: ✭ 526 (+1095.45%)
Mutual labels:  graphql, schema
Body Parser
Node.js body parsing middleware
Stars: ✭ 4,962 (+11177.27%)
Mutual labels:  middleware, json
Type Graphql
Create GraphQL schema and resolvers with TypeScript, using classes and decorators!
Stars: ✭ 6,864 (+15500%)
Mutual labels:  graphql, schema
Sleekdb
Pure PHP NoSQL database with no dependency. Flat file, JSON based document database.
Stars: ✭ 450 (+922.73%)
Mutual labels:  json, schema
Merge Graphql Schemas
A utility library to facilitate merging of modularized GraphQL schemas and resolver objects.
Stars: ✭ 935 (+2025%)
Mutual labels:  graphql, schema
Asp.net Core Graphql Middleware
ASP.Net Core GraphQL Middleware
Stars: ✭ 38 (-13.64%)
Mutual labels:  graphql, middleware
Typegql
Create GraphQL schema with TypeScript classes.
Stars: ✭ 415 (+843.18%)
Mutual labels:  graphql, schema
Flatcc
FlatBuffers Compiler and Library in C for C
Stars: ✭ 434 (+886.36%)
Mutual labels:  json, schema

graphql-factory

Tools for building GraphQL

Announcements

  • Alpha releases have started...

  • Documentation on graphqlfactory.io is not currently up to date. This announcement will be removed when it is.

This project is currently undergoing a major re-write for v3.0.0. This will include

  • a more graphql-like api
  • updated GraphQL Factory Definition Format
  • custom execution which will allow
    • custom directive middleware support
    • tracing data for all resolves/middleware
  • Schema building tools
  • Schema language support
  • better code testing
  • and more...

v2.1.0 code is available in the v2.1.0 branch. The master branch will be used for v3.0.0 development

Schema Language Example

Create a schema from schema language and a SchemaBacking

import { graphql } from 'graphql'
import {
  SchemaDefinition,
  SchemaBacking
} from 'graphql-factory'

// create a schema language definition
const definition = `
  type Item {
    id: String!
    name: String!
  }

  type List {
    id: String!
    name: String!
    items: [Item]!
  }

  type Query {
    listLists (search: String): [List]
  }

  directive @test(value: String) on SCHEMA | OBJECT | QUERY | FIELD

  schema @test(value: "I am a schema directive") {
    query: Query
  }`

// create a schema backing that contains resolvers
const backing = new SchemaBacking()
  .Directive('test')
    .before((source, args, context, info) => {
      console.log('Testing', args)
    })
  .Object('Query')
    .resolve('listLists', (source, args, context, info) => {
      // resolve code
    })
  .Object('List')
    .resolve('items', (source, args, context, info) => {
      // resolve code
    })
  .backing();

const schema = new SchemaDefinition()
    .use(definition, backing)
    .buildSchema();

schema.request({
  source: `
    query MyQuery {
      listLists {
        name
        items {
          name
        }
      }
    }
  `
})
.then(result => {
  // code...
});

Factory Definition Example

Create the same schema using GraphQL Factory Definition Format

import { graphql } from 'graphql'
import { SchemaDefinition } from 'graphql-factory'

// graphql factory definition which includes
// definitions and resolvers
const definition = {
  directives: {
    test: {
      locations: [ 'SCHEMA', 'OBJECT', 'QUERY', 'FIELD' ],
      args: {
        value: { type: 'String' }
      },
      before(source, args, context, info) {
        console.log('Testing', args)
      }
    }
  },
  types: {
    Item: {
      type: 'Object',
      fields: {
        id: { type: 'String!' },
        name: { type: 'String!' }
      }
    },
    List: {
      type: 'Object',
      fields: {
        id: { type: 'String!' },
        name: { type: 'String!' },
        items: {
          type: '[Item]!',
          resolve(source, args, context, info) {
            // resolve code
          }
        }
      }
    },
    Query: {
      type: 'Object',
      fields: {
        listLists: {
          type: '[List]',
          args: {
            search: { type: 'String' }
          },
          resolve(source, args, context, info) {
            // resolve code
          }
        }
      }
    }
  },
  schema: {
    directives: [ 'test' ],
    query: 'Query',
    '@directives': {
      test: {
        value: 'I am a schema directive'
      }
    }
  }
}

const schema = new SchemaDefinition()
    .use(definition, backing)
    .buildSchema();

schema.request({
  source: `
    query MyQuery {
      listLists {
        name
        items {
          name
        }
      }
    }
  `
})
.then(result => {
  // code...
});
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].