G.apex

  • Docs
  • Tutorials
Docs Menu
  • G.apex Core
    • Parameters
    • Default Value
    • Alias
    • Fragment
    • Variable
    • Directive
  • Editor
  • Methods
    • Global
    • Schema
    • Data Type
    • Resolver
    • Directive

Parameters Guide

Parameters

Define Parameters

G.Schema schema = new G.Schema()
    .add(
        new G.ObjectType('query')
            .addField('book', bookType, new GetBookResolver())
                .addParam('book', 'id', G.StringType, R.isNotNull)
    );

Compose Parameters

{
    "query": {
        "book": {
            "@id": "2",
            "name": "",
            "author": {
                 "name": ""
             }
        }
    }
}

Processing Parameters

private class GetBookResolver implements G.Resolver {
    public Object resolve(Map parent, Map args, G.ResolvingContext context) {
        return R.of(books).find(R.propEq.apply('id', args.get('id'))).toMap();
    }
}

Contribute on Github! Edit this section.