{"id":13563532,"url":"https://github.com/gqlc/gqlc","last_synced_at":"2025-10-20T04:49:17.034Z","repository":{"id":57518653,"uuid":"156631460","full_name":"gqlc/gqlc","owner":"gqlc","description":"GraphQL IDL Compiler","archived":false,"fork":false,"pushed_at":"2023-01-23T05:28:14.000Z","size":481,"stargazers_count":24,"open_issues_count":14,"forks_count":1,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-02-01T07:31:51.645Z","etag":null,"topics":["go","graphql","graphql-idl-compiler","graphql-schema","graphql-tools","javascript"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gqlc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2018-11-08T01:21:26.000Z","updated_at":"2023-01-23T05:10:02.000Z","dependencies_parsed_at":"2023-02-12T20:45:15.088Z","dependency_job_id":null,"html_url":"https://github.com/gqlc/gqlc","commit_stats":null,"previous_names":["zaba505/gqlc"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gqlc%2Fgqlc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gqlc%2Fgqlc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gqlc%2Fgqlc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gqlc%2Fgqlc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gqlc","download_url":"https://codeload.github.com/gqlc/gqlc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238536096,"owners_count":19488654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","graphql","graphql-idl-compiler","graphql-schema","graphql-tools","javascript"],"created_at":"2024-08-01T13:01:20.334Z","updated_at":"2025-10-20T04:49:11.989Z","avatar_url":"https://github.com/gqlc.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"[![GoDoc](https://godoc.org/github.com/gqlc/gqlc?status.svg)](https://godoc.org/github.com/gqlc/gqlc)\n[![Go Report Card](https://goreportcard.com/badge/github.com/gqlc/gqlc)](https://goreportcard.com/report/github.com/gqlc/gqlc)\n![build](https://github.com/gqlc/gqlc/workflows/build/badge.svg)\n[![codecov](https://codecov.io/gh/gqlc/gqlc/branch/master/graph/badge.svg)](https://codecov.io/gh/gqlc/gqlc)\n\n# GraphQL Compiler\n\n`gqlc` is a compiler for the GraphQL IDL, as defined by the [GraphQL spec](http://facebook.github.io/graphql).\nCurrent spec implementation: [Current Working Draft](https://graphql.github.io/graphql-spec/draft/)\n\n# Table of Contents\n\n- [Getting Started](#getting-started)\n  * [Installing](#installing)\n  * [Compiling Your First Schema](#compiling-your-first-schema)\n- [Supported Languages](#supported-languages)\n- [Contributing](#contributing)\n    * [Guidelines](#guidelines)\n    * [Code Generators](#code-generators)\n\n## Getting Started\nThis section gives a brief intro to using gqlc. For more information, check the\ndocs at [gqlc.dev](https://gqlc.dev).\n\n### Installing\nYou can either `git clone` this repo and build from source or download one of the prebuilt [releases](https://github.com/gqlc/gqlc/releases).\n\n### Compiling Your First Schema\nTo begin, lets use an abbreviated version of the schema used in the examples at [graphql.org](https://graphql.org/learn/schema/):\n\n```graphql\nschema {\n  query: Query,\n  mutation: Mutation\n}\n\ntype Query {\n  \"hero returns a character in an episode\"\n  hero(episode: Episode): Character\n}\n\ntype Mutation {\n  \"\"\"\n  addCharacter adds a new Character given their name and the episodes they appeared in.\n  \"\"\"\n  addCharacter(name: String!, episodes: [Episode!]!): Character\n}\n\n\"Episode represents the episodes of the Star Wars saga.\"\nenum Episode {\n  NEWHOPE\n  EMPIRE\n  JEDI\n}\n\n\"Character represents a character in any episode of Star Wars.\"\ntype Character {\n  name: String!\n  appearsIn: [Episode]!\n}\n```\n\nNow, that we have the schema for our GraphQL service it's time to start\nimplementing it. Typically, when implementing a GraphQL service you're thinking\nin terms of the IDL, but not writing in it; instead, you're writing in whatever\nlanguage you have chosen to implement your service in. This is where `gqlc`\ncomes in handy, by providing you with a tool that can \"compile\", or translate,\nyour IDL definitions into source code definitions. To accomplish this, simply\ntype the following into your shell:\n\n```bash\ngqlc --js_out . --doc_out . schema.gql\n```\n\n`gqlc` will then generate two files:\n\n*schema.js*: The js generator will output Javascript types for the schema.\n```javascript\nvar {\n  GraphQLSchema,\n  GraphQLObjectType,\n  GraphQLEnumType,\n  GraphQLList,\n  GraphQLNonNull,\n  GraphQLString\n} = require('graphql');\n\nvar Schema = new GraphQLSchema({\n  query: Query,\n  mutation: Mutation\n});\n\nvar EpisodeType = new GraphQLEnumType({\n  name: 'Episode',\n  values: {\n    NEWHOPE: {\n      value: 'NEWHOPE'\n    },\n    EMPIRE: {\n      value: 'EMPIRE'\n    },\n    JEDI: {\n      value: 'JEDI'\n    }\n  }\n});\n\nvar QueryType = new GraphQLObjectType({\n  name: 'Query',\n  fields: {\n    hero: {\n      type: Character,\n      args: {\n        episode: {\n          type: Episode\n        }\n      },\n      resolve() { /* TODO */ }\n    }\n  }\n});\n\nvar MutationType = new GraphQLObjectType({\n  name: 'Mutation',\n  fields: {\n    addCharacter: {\n      type: Character,\n      args: {\n        name: {\n          type: new GraphQLNonNull(GraphQLString)\n        },\n        episodes: {\n          type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(Episode)))\n        }\n      },\n      resolve() { /* TODO */ }\n    }\n  }\n});\n\nvar CharacterType = new GraphQLObjectType({\n  name: 'Character',\n  fields: {\n    name: {\n      type: new GraphQLNonNull(GraphQLString),\n      resolve() { /* TODO */ }\n    },\n    appearsIn: {\n      type: new GraphQLNonNull(new GraphQLList(Episode)),\n      resolve() { /* TODO */ }\n    }\n  }\n});\n```\n\n*schema.md*: The doc generator will output CommonMark documentation for the\nschema.\n```commonmark\n# Documentation\n*This was generated by gqlc.*\n\n## Table of Contents\n- [Schema](#Schema)\n- [Objects](#Objects)\n\t* [Character](#Character)\n\t* [Mutation](#Mutation)\n\t* [Query](#Query)\n- [Enums](#Enums)\n\t* [Episode](#Episode)\n\n## Schema\n\n*Root Operations*:\n- query **([Query](#Query))**\n- mutation **([Mutation](#Mutation))**\n\n## Objects\n\n### Character\nCharacter represents a character in any episode of Star Wars.\n\n*Fields*:\n- name **(String!)**\n- appearsIn **([[Episode](#Episode)]!)**\n\n### Mutation\n\n*Fields*:\n- addCharacter **([Character](#Character))**\n\n\t  addCharacter adds a new Character\n\t*Args*:\n\t- name **(String!)**\n\t- episodes **([[Episode](#Episode)!]!)**\n\n### Query\n\n*Fields*:\n- hero **([Character](#Character))**\n\n\thero returns a character in an episode\n\n\t*Args*:\n\t- episode **([Episode](#Episode))**\n\n## Enums\n\n### Episode\nEpisode represents the episodes of the Star Wars saga.\n\n*Values*:\n- NEWHOPE\n- EMPIRE\n- JEDI\n```\n\nNow, all you have to do is fill in the resolvers and plug it into an http\nendpoint. All generators and the compiler, itself, support options to tweak\nthe output.\n\n## Supported Languages\nThe currently supported languages by gqlc for generation are:\n\n* [Documentation](https://commonmark.org) ([example](https://gqlc.dev/generators/documentation.html))\n* [Go](https://golang.org)                ([example](https://gqlc.dev/generators/go.html))\n* [Javascript](https://javascript.com)    ([example](https://gqlc.dev/generators/javascript.html))\n\n## Contributing\n\nThank you for wanting to help keep this project awesome!\n\nBefore diving right in, here are a few things to help your contribution be accepted:\n\n#### Guidelines\nWhen making any sort of contribution remember to follow the [Contribution guidelines](https://github.com/gqlc/gqlc/blob/master/CONTRIBUTING.md).\n\n#### Code Generators\nNot every language can be supported directly, so please first create an issue and discuss adding support for your language there.\nIf the community shows enough consensus that your language should be directly supported, then a @gqlc team member will initialize\nthe repository for it and work can commence on implementing it.\n\nIf your desired language doesn't show enough support from the community to deem direct support in gqlc, then implementing a plugin\nis highly encouraged. Check out the [plugin docs](https://gqlc.dev/plugin/) for more information on how plugins are expected to behave when interacting with gqlc.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgqlc%2Fgqlc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgqlc%2Fgqlc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgqlc%2Fgqlc/lists"}