Chapter 04 (Understanding GraphQL) - Intuit-London/imperial-react-workshop GitHub Wiki
Start GraphQL Server
- Clone the project from
https://github.com/Intuit-London/invoice-graphql.git
- Navigate to the cloned invoice-graphql folder and Run the command
./gradlew build && java -jar build/libs/invoice-grapqhl-1.0-SNAPSHOT.jar
For Windows: gradlew.bat build && java -jar build/libs/invoice-grapqhl-1.0-SNAPSHOT.jar
- Install Chrome browser extension
chromeiql to execute graphql queries.
- Set endpoint as
http://localhost:8080/graphql
Read Calls
- Execute following queries
{
users {
id,
firstName,
invoices {
number,
creationDate,
totalAmount,
totalAmount
}
}
}
- Making use of
fragments
{
users {
id,
firstName,
invoices {
...invoicedetails
}
}
}
fragment invoicedetails on Invoice {
number,
paymentDate,
creationDate,
totalAmount
}
Mutations
- Sample mutation to create a Invoice
mutation InvoiceMutation {
createInvoice(input: {
clientMutationId: "client-mutation-1",
invoice: {
user: {
id: "L1VzZXI6dXNlci0x"
},
number: 1234,
customer: {
id: "customer-2",
businessName: "Juan"
},
creationDate: "25-06-2016",
paymentDate: "28-06-2016",
paid: true,
totalAmount: 100
}
}) {
clientMutationId
invoice {
user {
id
}
number
totalAmount
}
}
}