GraphQL mutations
Learn the basics of writing mutations using GraphQL.
A mutation is a type of operation that can modify server-side data. In GraphQL,
mutations must be explicitly specified by including the mutation
keyword before the
query. For additional information see the GraphQL Mutations topic on graphql.org.
GraphQL mutations have all the same benefits and efficiencies as the queries mentioned in the GraphQL query basics.
Work with mutations
If you want to write to the database, create a mutation type as in the following example:
type Mutation {
insertCustomer(
creditCard: String = ""
label: String = ""
street: String = ""
city: String = ""
postalCode: String = ""
countryRegion: String = ""
stateProvince: String = ""
email: String!
name: String!
): Customer
@dbquery(
type: "mysql"
table: "customer"
dml: INSERT
configuration: "mysql_config"
)
}
The mutation insertCustomer
accepts parameters for all of the columns available
on the customer
table. API Connect Essentials performs the necessary database
insert.