Postgraphile: Mutation cargo edge missing cursor field

Created on 17 Jan 2018  ·  6Comments  ·  Source: graphile/postgraphile

I'm submitting a ...

  • [x] bug report
  • [ ] feature request
  • [ ] question

PostGraphQL version:

4.0.0-alpha2.28

Minimal SQL file that can be loaded into a clean database:

CREATE TABLE foo (
  id  integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
  bar text NOT NULL
);

Steps to reproduce:

Config: classicIds: true

Mutation

mutation updateFooMutation($input: UpdateFooInput!) {
  updateFoo(input: $input) {
    clientMutationId
    fooEdge {
      cursor
      node {
        id
        bar
      }
    }
  }
}

Query Variables

{
  "input": {
    "clientMutationId": "base-64-encoded-identifier", 
    "id": "base-64-encoded-tuple",
    "fooPatch": {
      "bar": "baz"
    }
  }
}

Current behavior:

The cursor field returns null.

{
  "data": {
    "updateFoo": {
      "clientMutationId": "base-64-encoded-identifier",
      "fooEdge": {
        "cursor": null,
        "node": {
          "id": "base-64-encoded-tuple",
          "bar": "baz"
        }
      }
    }
  }
}

Expected behavior:

The cursor field should return a valid cursor.

{
  "data": {
    "updateFoo": {
      "clientMutationId": "base-64-encoded-identifier",
      "fooEdge": {
-       "cursor": null,
+       "cursor": "base-64-encoded-cursor",
        "node": {
          "id": "base-64-encoded-tuple",
          "bar": "baz"
        }
      }
    }
  }
}
🐛 bug 👨‍💻 Fix in v4

All 6 comments

This also affects PostgreSQL 9.6-style tables:

CREATE TABLE foo (
  id  serial PRIMARY KEY,
  bar text NOT NULL
);

temporary workaround using rowId

mutation updateFooMutation($input: UpdateFooInput!, $rowId: Int!) {
  updateFoo(input: $input) {
    clientMutationId
    query {
      allFoos(condition: {rowId: $rowId}) {
        edges {
          cursor
          node {
            id
            bar
          }
        }
      }
    }
  }
}

Looking into this now.

So turns out this was an issue in v3 also; so while trying to adhere to the v3 test suite I didn't notice the omission.

4 hours of coding later I've fixed it; that was a lot harder than I anticipated! 😅

Was this page helpful?
0 / 5 - 0 ratings