• 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

Directives

We can control the behavior of the G.apex query by applying directives.

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

Here #include is a directive, which will include fields of book only when if is true. As we are in JSON, we have to quote variables with double quotes. But it does not matter as G.apex will still correctly parse its value according to the data type we have specified.

Directives in G.apex start with #. We can also define custom directives in G.apex.