G.apex

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

Fragment Guide

Fragment

Use Fragments

{
    "query": {
        "book": {
            "@id": "2",
            "name": "",
            "...author": ""
        }
    },
    "...author": {
        "author": {
            "name": ""
        }
    }
}
 
1
{
2
    "query": {
3
        "book": {
4
            "@id": "2",
5
            "name": "",
6
            "...author": ""
7
        }
8
    },
9
    "...author": {
10
        "author": {
11
            "name": ""
12
        }
13
    }
14
}

We define fragments by prepending ... before the name and placing them at the root of the query. The result will be like:

{
    "query": {
        "book": {
            "author": {
                "name": "First Author"
            },
            "name": "Second Book"
        }
    }
}
10
 
1
{
2
    "query": {
3
        "book": {
4
            "author": {
5
                "name": "First Author"
6
            },
7
            "name": "Second Book"
8
        }
9
    }
10
}

Contribute on Github! Edit this section.

  • Use Fragments20 sec read
    Copy