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).
- What order have elements for
Identifierscollection? - Is there a correct way to define correct order (or names) of
Identifierselements for generation correct SQL query?
Will be grateful for any help/suggestions.
The order of the identifiers is the same as the order of the columns in the primary key constraint in the table; for example:
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.