BowlingX/ra-postgraphile

nodeId and id are different fields

mabilbao opened this issue · 2 comments

Hi! ✋ I am using Postgraphile for a project and I need to make a simple admin with a couple of CRUDs, so I decided to use react-admin and this library to wrap the data provider. When I try to list the first table I am getting this error:

message: "Fields "id" conflict because nodeId and id are different fields. Use different aliases on the fields to fetch both if this was intentional."
stack: "GraphQLError: Fields "id" conflict because nodeId and id are different fields. Use different aliases on the fields to fetch both if this was intentional.
    at Object.SelectionSet (/home/node/test-admin/packages/database/node_modules/graphql/validation/rules/OverlappingFieldsCanBeMerged.js:80:29)
    at Object.enter (/home/node/test-admin/packages/database/node_modules/graphql/language/visitor.js:334:29)
    at Object.enter (/home/node/test-admin/packages/database/node_modules/graphql/language/visitor.js:385:25)
    at visit (/home/node/test-admin/packages/database/node_modules/graphql/language/visitor.js:252:26)
    at Object.validate (/home/node/test-admin/packages/database/node_modules/graphql/validation/validate.js:63:22)
    at parseQuery (/home/node/test-admin/packages/database/node_modules/postgraphile/src/postgraphile/http/createPostGraphileHttpRequestHandler.ts:367:32)
    at /home/node/test-admin/packages/database/node_modules/postgraphile/src/postgraphile/http/createPostGraphileHttpRequestHandler.ts:718:55
    at Array.map (<anonymous>)
    at requestHandler (/home/node/test-admin/packages/database/node_modules/postgraphile/src/postgraphile/http/createPostGraphileHttpRequestHandler.ts:678:20)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)"

so, when I check the query I see that it is trying to redefine the field id but I already have my primary key with the same name:

query profiles($offset: Int!, $first: Int!, $filter: ProfileFilter, $orderBy: [ProfilesOrderBy!]) {
  profiles(first: $first, offset: $offset, filter: $filter, orderBy: $orderBy) {
    nodes {
      id: nodeId
      nodeId
      id
      name
      __typename
    }
    totalCount
    __typename
  }
}

My table:

CREATE TABLE profile (
	id uuid NOT NULL DEFAULT uuid_generate_v1mc(),
	name text NULL,
	created_at timestamp NOT NULL DEFAULT now(),
	updated_at timestamp NOT NULL DEFAULT now(),
	CONSTRAINT profile_pkey PRIMARY KEY (id)
);

Do you know what I am doing wrong?

I am using:

  • postgraphile version 4.6.0
  • ra-postgraphile: 4.2.0
  • react-admin: ^3.10.2

Thanks!

Hi :), sorry for the late reply.
This looks like a bug, I will have a look.

I can't reproduce the error on the e2e tests. It looks like somehow it does not detect your id type. Can you provide the introspection result? See here for the test: https://github.com/BowlingX/ra-postgraphile/blob/master/migrations/committed/000002.sql#L12