| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A sample GraphQL order management endpoint using GraphQL for .NET. This is a more advanced version of the example I used in my course API Development in .NET with GraphQL
This endpoint contains 2 core data types
Retrieves a list of orders
example:
query getOrders {
orders {
id
name
description
customer {
name
}
}
}
Retrieves a specified order
Arguments
example:
query getOrder {
orderById(orderId: "FAEBD971-CBA5-4CED-8AD5-CC0B8D4B7827") {
id
name
description
}
}
Retrieves all customers
example:
query getCustomers {
customers {
id
name
}
}
Creates an order
Arguments
example:
mutation createOrder{
createOrder(order:
{
name:"Glenn",
description:"Test",
customerId: 1,
created: "03/16/2018"
}
)
{
id
name
}
}
Starts the processing of an order. Can only be called if the order is in a CREATED state.
Arguments
example starting an order
mutation startOrder {
startOrder(orderId: "FAEBD971-CBA5-4CED-8AD5-CC0B8D4B7827") {
id
status
}
}
Finishes the processing of an order. Can only be called if the order is in the PROCESSING state.
Arguments
example completing an order
mutation completeOrder {
completeOrder(orderId: "FAEBD971-CBA5-4CED-8AD5-CC0B8D4B7827") {
id
status
}
}
Cancels an order. Can only be called if the order is not in the COMPLETED or CANCELLED state.
Arguments
example cancelling an order
mutation cancelOrder {
cancelOrder(orderId: "FAEBD971-CBA5-4CED-8AD5-CC0B8D4B7827") {
id
status
}
}
Closes an order. Can only be called if the order is in the COMPLETED state.
Arguments
example closing an order
mutation closeOrder {
closeOrder(orderId: "FAEBD971-CBA5-4CED-8AD5-CC0B8D4B7827") {
id
status
}
}
You can use subscriptions to get notified when an order is created. This relies on the awesome GraphQL Server project.
To test out subscriptions, you'll want to open two graphiql instances. One for subscribing, and the other for performing a mutation.
Notifies when order status changes.
Arguments
example subscribing to all order updates
subscription createdEvent {
orderEvent {
id
name
status
}
}
example subscribing to order started events
subscription startedEvent {
orderEvent ([PROCESSING]) {
id
name
status
}
}
Apache 2.0
| Back | FazBrowse Home | New Git URL |