PostGraphile GraphQL examples

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
{
  allForums {
    nodes {
      nodeId
      id
      slug
      name
      description
    }
  }
}
{
  "allForums": {
    "nodes": [
      {
        "nodeId": "WyJmb3J1bXMiLDFd",
        "id": 1,
        "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": "WyJmb3J1bXMiLDJd",
        "id": 2,
        "slug": "dog-life",
        "name": "Dog Life",
        "description": ""
      },
      {
        "nodeId": "WyJmb3J1bXMiLDNd",
        "id": 3,
        "slug": "slug-life",
        "name": "Slug Life",
        "description": ""
      }
    ]
  }
}