• 1Installation
  • 2Preliminary Knowledge
  • 3G.apex Demo
  • 4G.apex Query
  • 5Create Object Types
  • 6Create Schema
  • 7Resolver Functions
  • 8Serve Query Request
  • 9Mutation
  • 10Parameters
  • 11Default Value
  • 12Aliases
  • 13Fragments
  • 14Variables
  • 15Directives

G.apex

  • Docs
  • Tutorials
Getting started with G.apex

Create Schema

We need to define access points on our schema so that our data is accessible.

G.Schema schema = new G.Schema()
    .add(
        new G.ObjectType('query')
            .addField('books', new G.ListType(bookType), R.constant.apply(new List{ books }))
    );

Here we defined a new ObjectType query, with the field books that can retrive a list of books. Then we add this object type to the schema. R.constant.apply(...) here is a resolver Func that always returns the list of list of books whenever called. A resolver can be implemented by either a Func or an instance of BatchResolver or Resolver.

You might feel strange why we return a list of list of books. The reason is that by default our resolver function is invoked by batch to improve performance. We will see this later.

Done