Handle columns named `node_id`
Summary
Adding a column named node_id to any table causes postgraphile to emit an error like this, and prevents schema generation:
Error occurred during watch schema generation: Error: Expected an output type named 'ExecutionStep', but that type was not successfully constructed; typically this is because it ended up with no fields.
I assume that there isn't a way to have it work with columns named node_id, since this is part of global object identification spec.
Steps to reproduce
Create a column named node_id
Expected results
Postgraphile should probably show a more helpful error message.
Actual results
See above
Additional context
N/A
Possible Solution
create table node_id (id serial primary key, node_id int);
insert into node_id (node_id) values (null), (1), (2);
{
allNodeIds {
nodes {
id
nodeId
}
}
}
{
"data": {
"allNodeIds": {
"nodes": [
{
"id": "WyJub2RlX2lkcyIsMV0=",
"nodeId": null
},
{
"id": "WyJub2RlX2lkcyIsMl0=",
"nodeId": 1
},
{
"id": "WyJub2RlX2lkcyIsM10=",
"nodeId": 2
}
]
}
},
"extensions": {
"number": -1
}
}
Okay if you're not using the Relay preset then node_id column name will conflict with the default nodeId: ID field. It'll give you a conflict error though:
graphile-build:warn Recoverable error occurred: Error: A naming conflict has occurred - two entities have tried to define the same key 'nodeId'.
The first entity was:
Adding id field to NodeId type from AddNodeInterfaceToQueryPlugin
The second entity was:
Adding 'node_id' attribute field to GraphQL type 'NodeId' (representing PgCodec 'nodeId').
Details: https://err.red/pnc
We should add a diagnostic for this to tell people to either:
- Use the relay preset (such that
nodeId: ID!becomesid: ID!instead) - Rename the column in the database
- Rename the column in GraphQL using smart tags
- Rename all
node_idcolumns by overriding the_attributeNameinflector - Disable
NodePluginsonodeId: ID!isn't added in the first place
I don't see this as a bug; this is an expected behavior (you can't have two things called nodeId for the same type).
I wasn't able to find how you managed to get it to give the error you listed.