Example queries and mutations

If you are new to GraphQL then I recommend you read through the official introduction to GraphQL here before continuing through the PostGraphile documentation.

Below, you'll find the result of running various GraphQL queries against the examples repo schema. This is intended to be an introduction and quick reference, for full information please use the documentation links.

Please be aware that these examples use the @graphile-contrib/pg-simplify-inflector plugin to simplify the field names over the defaults. You can use this via the following commands:

yarn add postgraphile @graphile-contrib/pg-simplify-inflector
yarn postgraphile --append-plugins @graphile-contrib/pg-simplify-inflector

  • Basic
    • Forums
    • Forum by slug
  • Collections
  • Relations
  • Mutations
  • Custom queries
  • Custom mutations
  • Computed columns
{
  forums {
    nodes {
      nodeId
      id
      slug
      name
      description
    }
  }
}
{
  "forums": {
    "nodes": [
      {
        "nodeId": "WyJmb3J1bXMiLDFd",
        "id": 1,
        "slug": "testimonials",
        "name": "Testimonials",
        "description": "How do you rate PostGraphile?"
      },
      {
        "nodeId": "WyJmb3J1bXMiLDJd",
        "id": 2,
        "slug": "feedback",
        "name": "Feedback",
        "description": "How are you finding PostGraphile?"
      },
      {
        "nodeId": "WyJmb3J1bXMiLDNd",
        "id": 3,
        "slug": "cat-life",
        "name": "Cat Life",
        "description": "A forum all about cats and how fluffy they are and how they completely ignore their owners unless there is food. Or yarn."
      },
      {
        "nodeId": "WyJmb3J1bXMiLDRd",
        "id": 4,
        "slug": "cat-help",
        "name": "Cat Help",
        "description": "A forum to seek advice if your cat is becoming troublesome."
      }
    ]
  }
}