{"repo":"graphql-crystal/graphql","free":true,"listed":false,"github":"https://github.com/graphql-crystal/graphql","clone":"git clone https://github.com/graphql-crystal/graphql.git","description":"GraphQL server library for Crystal","language":"Crystal","stars":139,"topics":["graphql","crystal"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"GraphQL server library for Crystal. - Boilerplate-free : Schema generated at compile time - Type-safe : Crystal guarantees your code matches your schema - High performance : See benchmarks Getting Started Install the shard by adding the following to our shard.yml : Then run shards install . The first step is to define a query object. This is the root type for all queries and it looks like this: Now we can create a schema object: To verify we did everything correctly, we can print out the schema: Which, among several built-in types, prints our query type: To serve our API over HTTP we call schema.execute with the request parameters and receive a JSON string. Here is an example for Kemal: Now we're ready to query our API: This should return: For easier development, we recommend using GraphiQL. A starter template combining Kemal and GraphiQL is found at examples/graphiql. Context context is a optional argument that our fields can retrieve. It lets fields access global data, like database connections. Context instances must not be reused for multiple executions. Objects Objects are perhaps the most commonly used type in GraphQL. They are implemented as classes. To define a object, we need a GraphQL::Object annotation and to inherit GraphQL::BaseObject . Fields are methods with a GraphQL::Field annotation. For simple objects, we can use instance variables: Query Query is the root type of all queries. Mutation Mutation is the root type for all mutations. Input Objects Input objects","default_branch":null,"files":null,"tree":[],"storefront":"/r/graphql-crystal","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/graphql-crystal/graphql/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}