EDIT: I'm going to give the SQL equivalents here because its the easiest way I can convey what I'm trying to find an equivalent to.
The schema for a person
is
id (system assigned clustered PK, probably a guid, doesnt really matter for this)
FirstName : string
LastName : string, required
EmployeeCode : string, required, Unique
I want to be able to represent a query like this in GraphQL (BEGIN/END ommitted for brevity), and just the UPDATE statement and I need examples for either that shows how to target specific records like the WHERE clause does.
IF EXISTS(SELECT TOP 1 1 FROM person WITH (UPDLOCK) WHERE EmployeeCode = 'ABC123')
UPDATE person
SET FirstName = 'Mike'
, LastName = 'Jones'
WHERE EmployeeCode = 'ABC123
ELSE
INSERT person (FirstName, LastName, EmployeeCode)
VALUES ('Mike', "Hones', 'ABC123')
The GraphQl spec discusses mutations but not what it looks like. The examples only cover the INSERT scenario. The only mention about updates is that they will/must/? be executed consecutively.
Original question -
I want to be able to send a single graphql document to add a record if none exist for the criteria specified, or update (partial or all non ident/non PK/non NK fields) an existing one if the criteria specified match an existing record.
I can do this a few ways in conventional SQL dialects and in ElasticSearch (update by query). But I dont see how its supposed to be specified or described within graphql - or if its even possible.
In the spec and on the web there are some examples for adding records that seem to require things that look like they are "extra" or "nice to have" (like schema/type definitions) to be included in the document. The update examples often have field, argument, and variable names that dont match (like Author.Id and authorId), or are written using a non-graphql specific language like Javascript (same example page as "Author".) Doing this two stage operation from the end client doesnt seem like the correct approach either as only the target data store is going to know which is the correct operation to take.
There will not be a fixed predefined centralized schema for what I'm working on as its a muilti-tenant API and each tenant may have different definitions for a type (for example Tenant A has a Contract entity with 16 fields, but Tenant B has a type of the same name and intended function with 20 field. Both would share the same storage space for Contracts.
Is any what I'm asking about for even possible? If so can an example be shared?