All Projects → rigglo → gql

rigglo / gql

Licence: MIT License
This is a GraphQL server written in Go

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to gql

decapi
Create GraphQL API by decorating TypeScript classes
Stars: ✭ 81 (+161.29%)
Mutual labels:  schema, gql
Type Graphql
Create GraphQL schema and resolvers with TypeScript, using classes and decorators!
Stars: ✭ 6,864 (+22041.94%)
Mutual labels:  schema, gql
twitch-graphql-api
KomodoHype
Stars: ✭ 78 (+151.61%)
Mutual labels:  gql
craftql
A CLI tool to visualize GraphQL schemas and to output a graph data structure as a graphviz .dot format
Stars: ✭ 75 (+141.94%)
Mutual labels:  schema
openapi-schema-validator
OpenAPI schema validator for Python
Stars: ✭ 35 (+12.9%)
Mutual labels:  schema
schema-shot
Framework-agnostic snapshot testing using "schema by example" for highly dynamic data
Stars: ✭ 34 (+9.68%)
Mutual labels:  schema
linkedin-to-jsonresume
Browser extension to turn a LinkedIn profile page into a JSON Resume export.
Stars: ✭ 93 (+200%)
Mutual labels:  schema
superstruct
Rust library for versioned data types
Stars: ✭ 27 (-12.9%)
Mutual labels:  schema
data-models
Collection of various biomedical data models in parseable formats.
Stars: ✭ 23 (-25.81%)
Mutual labels:  schema
tyshemo
A javascript runtime data type checking system and morden reactive state management model.
Stars: ✭ 70 (+125.81%)
Mutual labels:  schema
Clockwork
A roleplaying framework developed by Cloud Sixteen for the people.
Stars: ✭ 37 (+19.35%)
Mutual labels:  schema
gbXML Schemas
Includes current and previous versions of the Green Building XML (gbXML) schema
Stars: ✭ 22 (-29.03%)
Mutual labels:  schema
ckanext-scheming
Easy, shareable custom CKAN schemas
Stars: ✭ 67 (+116.13%)
Mutual labels:  schema
thema
A CUE-based framework for portable, evolvable schema
Stars: ✭ 41 (+32.26%)
Mutual labels:  schema
starlette-graphql
The starlette GraphQL implement, which support query, mutate and subscription.
Stars: ✭ 15 (-51.61%)
Mutual labels:  apollo-federation
haskell-schema
A library for describing Haskell data types and obtain free generators, JSON codecs, pretty printers, etc.
Stars: ✭ 16 (-48.39%)
Mutual labels:  schema
Insulator
A client UI to inspect Kafka topics, consume, produce and much more
Stars: ✭ 53 (+70.97%)
Mutual labels:  schema
normalize-pkg
Normalize values in package.json to improve compatibility, programmatic readability and usefulness with third party libs.
Stars: ✭ 18 (-41.94%)
Mutual labels:  schema
ecto generator
Generate Ecto schemas from existing database in Phoenix - Elixir
Stars: ✭ 20 (-35.48%)
Mutual labels:  schema
the schema is
ActiveRecord schema annotations done right
Stars: ✭ 44 (+41.94%)
Mutual labels:  schema

gql

tests PkgGoDev Coverage Status

Note: As the project is still in WIP, there can be breaking changes which may break previous versions.

This project aims to fulfill some of the most common feature requests missing from existing packages, or ones that could be done differently.

Roadmap for the package

  • Custom scalars
  • Extensions
  • Subscriptions
  • Apollo Federation
  • Custom directives
    • Field directives
    • Executable directives
    • Type System directives
  • Opentracing
  • Query complexity
  • Apollo File Upload
  • Custom validation for input and arguments
  • Access to the requested fields in a resolver
  • Custom rules-based introspection
  • Converting structs into GraphQL types
  • Parse inputs into structs

Examples

There are examples in the examples folder, these are only uses this gql package, they don't have any other dependencies.

Additional examples can be found for Apollo Federation, Subscriptions in the rigglo/gql-examples repository.

Getting started

Defining a type, an object is very easy, let's visit a pizzeria as an example.

var PizzaType = &gql.Object{  
   Name: "Pizza",  
   Fields: gql.Fields{
      "id": &gql.Field{
         Description: "id of the pizza",
         Type:        gql.ID,
      },
      "name": &gql.Field{
         Description: "name of the pizza",
         Type:        gql.String,
      },
      "size": &gql.Field{
         Description: "size of the pizza (in cm)",
         Type:        gql.Int,
      },
   },
}

Next, we need a way to get our pizza, to list them, so let's define the query.

var RootQuery = &gql.Object{  
   Name: "RootQuery",  
   Fields: gql.Fields{
      "pizzas": &gql.Field{
         Description: "lists all the pizzas",    
         Type:        gql.NewList(PizzaType),
         Resolver: func(ctx gql.Context) (interface{}, error) {
            return []Pizza{
               Pizza{
                  ID:1, 
                  Name: "Veggie", 
                  Size: 32,
               },
               Pizza{
                  ID:2, 
                  Name: "Salumi", 
                  Size: 45,
               },
            }, nil
         },
      },
   }, 
}

To have a schema defined, you need the following little code, that connects your root query and mutations (if there are) to your schema, which can be later executed.

var PizzeriaSchema = &gql.Schema{
   Query: RootQuery,
}

At this point, what's only left is an executor, so we can run our queries, and a handler to be able to serve our schema.

For our example, let's use the default executor, but if you want to experiment, customise it, add extensions, you can create your own the gql.NewExecutor function.  Let's fire up our handler using the github.com/rigglo/gql/pkg/handler package and also enable the playground, so we can check it from our browser.

func main() {
   http.Handle("/graphql", handler.New(handler.Config{
      Executor:   gql.DefaultExecutor(PizzeriaSchema),
      Playground: true,
   }))
   if err := http.ListenAndServe(":9999", nil); err != nil {
      panic(err)
   }
}

After running the code, you can go to the http://localhost:9999/graphql address in your browser and see the GraphQL Playground, and you can start playing with it.

NOTES

Directives

Adding directives in the type system is possible, but currently only the field directives are being executed.

Apollo Federation

The support for Apollo Federation is provided by the github.com/rigglo/gql/pkg/federation package, which adds the required fields, types and directives to your schema.

SDL

The support for generating SDL from the Schema is not production ready, in most cases it's enough, but it requires some work, use it for your own risk.

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