Mutation mapping schema NReco.GraphQL documentation
To perform CUD (create/update/delete) actions to your DB tables as GraphQL objects mapping schema needs to be configured in the MutationObjects section:
{
"MutationSchemaObjects": [
{
"Name": "Customer",
"Table": "Customers",
"Create": "AddCustomer",
"Fields": [
{ "Name": "id", "Column": "CustomerID", "DataType": "string", "PrimaryKey": true },
{ "Name": "CompanyName", "DataType": "string" },
{ "Name": "ContactName", "DataType": "string" }
]
}
]
}
Field definition
The section is an array of MutationSchema objects. Each object supports the properties listed below.
| Property | Type | Description |
|---|---|---|
Name | string (optional) | Logical name of the GraphQL object. Used to compose mutation function names, the input-payload type, and variable names. If omitted, Table is used. |
Create | string (optional) | Name of the add mutation. Defaults to Create<Name>. |
Update | string (optional) | Name of the update mutation. Defaults to Update<Name>. |
Delete | string (optional) | Name of the delete mutation. Defaults to Delete<Name>. |
Table | string | Underlying database table mapped to this object. |
Description | string (optional) | Object description exposed through the GraphQL schema. |
Fields | array | Collection of field definitions (see below). |
Note: If the array contains at least one mutation object, a mutation section will automatically be added to the generated GraphQL schema.
Using generated mutations
| Mutation | GraphQL query | Variables |
|---|---|---|
CreateAddCustomer |
|
|
UpdateUpdateCustomer |
|
|
DeleteDeleteCustomer |
|
|