Reputation: 2714
We implemented a Postgraphile mutation plugin using method makeExtendSchemaPlugin.
In our plugin we use NodeId
and we parse this NodeId using method getTypeAndIdentifiersFromNodeId
. This method returns GraphQL Type
and collection of Identifiers
.
If our type has only one PrimaryKey
column then we don't have any issues. We use only first element of Identifiers
collection. And we can generate our SQL script without any troubles.
If we have composite PrimaryKey
then Identifiers
collection has multiple elements (as expected).
Identifiers
collection?Identifiers
elements for generation correct SQL query?Will be grateful for any help/suggestions.
Upvotes: 0
Views: 88
Reputation: 7946
The order of the identifiers is the same as the order of the columns in the primary key constraint in the table; for example:
create table attendance (
module_id int not null,
student_id int not null,
primary key (student_id, module_id)
);
In this case the order of identifiers would be: student_id, module_id.
You can determine the names of the identifiers by looking at the associated columns in the primary key constraint.
Upvotes: 2