Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - adding mutations docs #44

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ In some cases it offers different formats of the same data. For example, you may

Similarly you can retrieve product measurements in millimeters, centimeters, or inches, or weights in grams or ounces.

Using mutations you can also make changes to the data and return query results. With this powerful feature you have the potential to modify products, automate tasks or build a completely bespoke metadata management front end.

So the main benefit to using the GraphQL API is that it is excellent at dealing with complex data relations. If you want only works of a particular series, their ebook PDF products, their contributors, and the library prices for the products. To represent this in a CSV file would require a set of columns for the work, one set per product, another set for each contributor, and more columns for each price. Pretty soon your spreadsheet is at column HS, has column names like "product\_1\_price\_4" and "contributor\_3\_last\_name", and is unreadable.

In a GraphQL response these relations are expressed in a JSON response that is structured in the same way as your original query, and is readable by any popular programing language. Or even by a human being.
Expand Down
12 changes: 8 additions & 4 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
* [Select products filtered by price and format](examples/products\_filtered\_by\_price\_and\_format.md)
* [Select products filtered by work attributes](examples/products\_filtered\_by\_work\_attributes.md)
* [Select works and their relevant marketing material](examples/works\_and\_marketing\_material.md)
* [Sample AI/Tip Sheet](examples/sample\_ai.md)
* [Update work to change its title](examples/update_work_title.md)
* [Update product to assign an ISBN](examples/update_product_add_isbn.md)
* [Update a publication status from forthcoming to active](examples/update_product_pub_status.md)
* [Update prices](examples/update_prices.md)
* [Generate a sample AI/Tip Sheet](examples/sample\_ai.md)
* Production
* [Select works and their product production run details](examples/works\_and\_product\_production\_run\_details.md)
* [Sample production request form](/examples/sample\_production\_request\_form.md)
* [Generate a sample production request form](/examples/sample\_production\_request\_form.md)
* Data exchange
* [Sample custom report sheet](/examples/sample\_custom\_report.md)
* [Sample dashboard](examples/sample\_dashboard.md)
* [Generate a sample custom report sheet](/examples/sample\_custom\_report.md)
* [Generate a sample dashboard](examples/sample\_dashboard.md)
45 changes: 45 additions & 0 deletions examples/update_prices.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Description

Update prices on a product

## Explanation

This mutation updates all the prices based on a Work ID and a pricing scope.

```gql
mutation UpdateWorkPrices($id: ID!, $pricingScope: String!, $productInputs: [UpdateProductInput!]!) {
updateWork(id: $id, productInputs: $productInputs, scope: $pricingScope) {
work {
id
title
prices {
id
priceAmount
}
}
errors {
field
message
}
}
}
```

Then add the variables to the "Query Variables" section.

```gql
{
"id": "1",
"pricingScope": "01-05-02-05",
"productInputs": [
{
"id": "1",
"price": 9.99
},
{
"id": "2",
"price": 12.99
}
]
}
```
33 changes: 33 additions & 0 deletions examples/update_product_add_isbn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Description

Update a product to assign an ISBN

## Explanation

This mutation will update the product's isbn field and return the updated product record and any validation errors that occurred during the update process.

```gql
mutation UpdateProduct($id: ID!, $isbn: String!) {
updateProduct(input: {
id: $id,
isbn: $isbn
}) {
product {
id
isbn
}
errors {
attribute
message
}
}
}
```

Then add the two variables to the "Query Variables" section.

{
"id": PRODUCT_ID_HERE,
"isbn": "NEW_ISBN_HERE"
}

35 changes: 35 additions & 0 deletions examples/update_product_pub_date.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Description

Update the publication date of a product

## Explanation

This mutation updates the publication date of a product, specified by its product ID. The results are then displayed as part of the query.

```gql
mutation UpdateProductPublicationDate($input: UpdateProductInput!) {
updateProduct(input: $input) {
product {
id
isbn
title
publicationDate
}
errors {
field
messages
}
}
}
```

Then add the variables to the "Query Variables" section.

```gql
{
"input": {
"id": 123,
"publicationDate": "2023-04-01"
}
}
```
37 changes: 37 additions & 0 deletions examples/update_product_pub_status.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Description

Update the publication status of a product

## Explanation

This mutation updates the publication status of a product, specified by its product ID. The results are then displayed as part of the query.

```gql
mutation UpdateProductOnixPublishingStatusCode($input: UpdateProductInput!) {
updateProduct(input: $input) {
product {
id
isbn
title
onixPublishingStatusCode
}
errors {
field
messages
}
}
}

```

Then add the variables to the "Query Variables" section.

```gql
{
"input": {
"id": 123,
"onixPublishingStatusCode": "04"
}
}

```
21 changes: 21 additions & 0 deletions examples/update_work_title.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Description

Update a work to amend its title

## Explanation

This mutation updates the work level title is changed on a specific work, specified by its work ID. The results are then displayed as part of the query.

```gql
mutation {
updateWork(input: {
id: [WORK_ID],
title: "Your New Title"
}) {
work {
id
title
}
}
}
```