• 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

Mutation

G.apex treats query and mutation similarly. We can define our mutation operations in the schema, and process the requests in the resolving functions.

G.Schema schema = new G.Schema()
    .add(
        new G.ObjectType('mutation')
            .addField('addBook', bookType, new AddBookResolver())
                .addParam('addBook', 'name', G.StringType, R.isNotNull)
    );

We add a parameter definition name of String type to the field addBook. Also this parameter has a validation of not-null specified by the R.isNotNull Func.

Done