All Projects → gqlc → gqlc

gqlc / gqlc

Licence: MIT license
GraphQL IDL Compiler

Programming Languages

go
31211 projects - #10 most used programming language
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to gqlc

graphql-spotify
GraphQL Schema And Resolvers For Spotify Web API
Stars: ✭ 55 (+139.13%)
Mutual labels:  graphql-schema, graphql-tools
graphql-compose-elasticsearch
Graphql App using Node with typescript, KOA framework and Elasticsearch
Stars: ✭ 40 (+73.91%)
Mutual labels:  graphql-schema, graphql-tools
schemaglue
Naturally breaks down your monolithic graphql schema into bits and pieces and then glue them back together.
Stars: ✭ 117 (+408.7%)
Mutual labels:  graphql-schema, graphql-tools
relay-compiler-plus
Custom relay compiler which supports persisted queries
Stars: ✭ 68 (+195.65%)
Mutual labels:  graphql-schema, graphql-tools
graphql-schema-diff
📄🔄📄 Returns the diff of two GraphQL schemas. Detects dangerous and breaking changes.
Stars: ✭ 54 (+134.78%)
Mutual labels:  graphql-schema
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 (+12982.61%)
Mutual labels:  graphql-schema
Graphql S2s
Add GraphQL Schema support for type inheritance, generic typing, metadata decoration. Transpile the enriched GraphQL string schema into the standard string schema understood by graphql.js and the Apollo server client.
Stars: ✭ 171 (+643.48%)
Mutual labels:  graphql-schema
Graphbrainz
A fully-featured GraphQL interface for the MusicBrainz API.
Stars: ✭ 130 (+465.22%)
Mutual labels:  graphql-schema
graphql-metadata
Annotate your graphql schema with lightweight directives
Stars: ✭ 28 (+21.74%)
Mutual labels:  graphql-schema
graphql-go-tools
Like apollo-tools for graphql-go
Stars: ✭ 22 (-4.35%)
Mutual labels:  graphql-tools
Prisma Tools
Prisma tools to help you generate CRUD system for GraphQL servers
Stars: ✭ 237 (+930.43%)
Mutual labels:  graphql-schema
Nexus
Code-First, Type-Safe, GraphQL Schema Construction
Stars: ✭ 2,722 (+11734.78%)
Mutual labels:  graphql-schema
graphql-example
GraphQL Sample Project
Stars: ✭ 32 (+39.13%)
Mutual labels:  graphql-tools
Graphql2rest
GraphQL to REST converter: automatically generate a RESTful API from your existing GraphQL API
Stars: ✭ 181 (+686.96%)
Mutual labels:  graphql-schema
envelop
Envelop is a lightweight library allowing developers to easily develop, share, collaborate and extend their GraphQL execution layer. Envelop is the missing GraphQL plugin system.
Stars: ✭ 630 (+2639.13%)
Mutual labels:  graphql-schema
Apollo Server
🌍  Spec-compliant and production ready JavaScript GraphQL server that lets you develop in a schema-first way. Built for Express, Connect, Hapi, Koa, and more.
Stars: ✭ 12,145 (+52704.35%)
Mutual labels:  graphql-schema
Graphql Weaver
A tool to combine, link and transform GraphQL schemas
Stars: ✭ 235 (+921.74%)
Mutual labels:  graphql-schema
graphql-cli-load
A graphql-cli data import plugin to call mutations with data from JSON/CSV files
Stars: ✭ 63 (+173.91%)
Mutual labels:  graphql-schema
Type O Rama
👾 JS type systems interportability
Stars: ✭ 217 (+843.48%)
Mutual labels:  graphql-schema
36 Graphql Concepts
📜 36 concepts every GraphQL developer should know.
Stars: ✭ 209 (+808.7%)
Mutual labels:  graphql-schema

GoDoc Go Report Card build codecov

GraphQL Compiler

gqlc is a compiler for the GraphQL IDL, as defined by the GraphQL spec. Current spec implementation: Current Working Draft

Table of Contents

Getting Started

This section gives a brief intro to using gqlc. For more information, check the docs at gqlc.dev.

Installing

You can either git clone this repo and build from source or download one of the prebuilt releases.

Compiling Your First Schema

To begin, lets use an abbreviated version of the schema used in the examples at graphql.org:

schema {
  query: Query,
  mutation: Mutation
}

type Query {
  "hero returns a character in an episode"
  hero(episode: Episode): Character
}

type Mutation {
  """
  addCharacter adds a new Character given their name and the episodes they appeared in.
  """
  addCharacter(name: String!, episodes: [Episode!]!): Character
}

"Episode represents the episodes of the Star Wars saga."
enum Episode {
  NEWHOPE
  EMPIRE
  JEDI
}

"Character represents a character in any episode of Star Wars."
type Character {
  name: String!
  appearsIn: [Episode]!
}

Now, that we have the schema for our GraphQL service it's time to start implementing it. Typically, when implementing a GraphQL service you're thinking in terms of the IDL, but not writing in it; instead, you're writing in whatever language you have chosen to implement your service in. This is where gqlc comes in handy, by providing you with a tool that can "compile", or translate, your IDL definitions into source code definitions. To accomplish this, simply type the following into your shell:

gqlc --js_out . --doc_out . schema.gql

gqlc will then generate two files:

schema.js: The js generator will output Javascript types for the schema.

var {
  GraphQLSchema,
  GraphQLObjectType,
  GraphQLEnumType,
  GraphQLList,
  GraphQLNonNull,
  GraphQLString
} = require('graphql');

var Schema = new GraphQLSchema({
  query: Query,
  mutation: Mutation
});

var EpisodeType = new GraphQLEnumType({
  name: 'Episode',
  values: {
    NEWHOPE: {
      value: 'NEWHOPE'
    },
    EMPIRE: {
      value: 'EMPIRE'
    },
    JEDI: {
      value: 'JEDI'
    }
  }
});

var QueryType = new GraphQLObjectType({
  name: 'Query',
  fields: {
    hero: {
      type: Character,
      args: {
        episode: {
          type: Episode
        }
      },
      resolve() { /* TODO */ }
    }
  }
});

var MutationType = new GraphQLObjectType({
  name: 'Mutation',
  fields: {
    addCharacter: {
      type: Character,
      args: {
        name: {
          type: new GraphQLNonNull(GraphQLString)
        },
        episodes: {
          type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(Episode)))
        }
      },
      resolve() { /* TODO */ }
    }
  }
});

var CharacterType = new GraphQLObjectType({
  name: 'Character',
  fields: {
    name: {
      type: new GraphQLNonNull(GraphQLString),
      resolve() { /* TODO */ }
    },
    appearsIn: {
      type: new GraphQLNonNull(new GraphQLList(Episode)),
      resolve() { /* TODO */ }
    }
  }
});

schema.md: The doc generator will output CommonMark documentation for the schema.

# Documentation
*This was generated by gqlc.*

## Table of Contents
- [Schema](#Schema)
- [Objects](#Objects)
	* [Character](#Character)
	* [Mutation](#Mutation)
	* [Query](#Query)
- [Enums](#Enums)
	* [Episode](#Episode)

## Schema

*Root Operations*:
- query **([Query](#Query))**
- mutation **([Mutation](#Mutation))**

## Objects

### Character
Character represents a character in any episode of Star Wars.

*Fields*:
- name **(String!)**
- appearsIn **([[Episode](#Episode)]!)**

### Mutation

*Fields*:
- addCharacter **([Character](#Character))**

	  addCharacter adds a new Character
	*Args*:
	- name **(String!)**
	- episodes **([[Episode](#Episode)!]!)**

### Query

*Fields*:
- hero **([Character](#Character))**

	hero returns a character in an episode

	*Args*:
	- episode **([Episode](#Episode))**

## Enums

### Episode
Episode represents the episodes of the Star Wars saga.

*Values*:
- NEWHOPE
- EMPIRE
- JEDI

Now, all you have to do is fill in the resolvers and plug it into an http endpoint. All generators and the compiler, itself, support options to tweak the output.

Supported Languages

The currently supported languages by gqlc for generation are:

Contributing

Thank you for wanting to help keep this project awesome!

Before diving right in, here are a few things to help your contribution be accepted:

Guidelines

When making any sort of contribution remember to follow the Contribution guidelines.

Code Generators

Not every language can be supported directly, so please first create an issue and discuss adding support for your language there. If the community shows enough consensus that your language should be directly supported, then a @gqlc team member will initialize the repository for it and work can commence on implementing it.

If your desired language doesn't show enough support from the community to deem direct support in gqlc, then implementing a plugin is highly encouraged. Check out the plugin docs for more information on how plugins are expected to behave when interacting with gqlc.

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].