graphqlpostgraphile

Can GraphQL operations/results format be simplified?


I'm using latest version of Postraphile (on its Docker container) and I've installed pg-simplify-inflector plugin, I've noted an improvement respect to names for operations, and I wish to get a simplified format for operations and their results. Example:

For this operation:

query MyQuery {
  iddocTypes {
    nodes {
      id
      name
    }
  }
}

with result:

{
  "data": {
    "iddocTypes": {
      "nodes": [
        {
          "id": 1,
          "name": "some 1"
        },
        {
          "id": 2,
          "name": "some 2"
        },
        {
          "id": 3,
          "name": "some 3"
        }
      ]
    }
  }
}

I wish to get this:

query MyQuery {
  iddocTypes {
    id
    name
  }
}

with result:

{
  "data": {
    "iddocTypes": [
      {
        "id": 1,
        "name": "some 1"
      },
      {
        "id": 2,
        "name": "some 2"
      },
      {
        "id": 3,
        "name": "some 3"
      }
    ]
  }
}

I'm using these options for Postgraphile in docker-compose.yml:

      "--dynamic-json",
      "--subscriptions",
      "--no-setof-functions-contain-nulls",
      "--no-ignore-rbac",
      "--no-ignore-indexes",
      "--show-error-stack", "json",
      "--extended-errors", "hint,detail,errcode",
      "--enable-query-batching",
      "--legacy-relations", "omit",
      "--append-plugins", "@graphile-contrib/pg-simplify-inflector",
      "--enhance-graphiql"

What do I need to do to simplify it?


Solution

  • Add this option:

          "--simple-collections", "only",
    

    Source: https://www.graphile.org/postgraphile/usage-cli/