G.apex

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

Directive Guide

Directive

Use Directives

{
    "query": {
        "book": {
            "#include": {
                "if": "$showBook"
            },
            "@id": "2",
            "name": ""
        }
    },
    "$showBook": "false"
}

We use the directives by prepending #.

The available directives are:

NameDescription
includeused with param 'if' to control if the object type is included
skipused with param 'if' to control if the object type is skipped

Custom Directives

We can define custom directives.

private class CustomDirective implements Directive {
    public String getName() {
        return 'custom';
    }

    public Boolean beforeExecuting(Map args, DirectiveContext context) {
        // ...
        return true;
    }
}

G.registerDirective(new CustomDirective());

Contribute on Github! Edit this section.