General Query Writing - HeadassHouse/loremaster-backend GitHub Wiki

The general structure is broken into two main pieces, the query, and the optional variables portion.

{ 
    "query": "query { login(userName: 'username', password: 'password') { _id userName } }",
    "variables": null  // Not using the variables portion
}
{ 
    "query": "mutation($account: AccountInput!) { createAccount(account: $account) { code } }",
    "variables": {  // Using the variables portion
        "account": {
            "userName": "bsmith382",
            "name":"Bob Smith",
            "email": "[email protected]",
            "password": "password"
        }
    }
}

This query is then sent as a post request to the /graphql endpoint.