This is an example to show how to get graphql works with springboot
Already have
- Query list
- Query with arguments
- Mutation
- Union type
- Field resolver
- Mutation with input type
- Fragment
- Nested query
To be added
- Defer
-
Download graphiql app
-
./gradlew bootrun -
Visit
http://localhost:8081/graphqlin GraphiQLquery { pets { ...on Bird { name type wings owner { name } } ...on Dog { name type license owner { name, address } } } }query { pet(id: 1) { ...on Bird { name type wings owner { name } } ...on Dog { name type license owner { name, address } } } }mutation { saveDog(id:-1, name: "XXX", age: 12, ownerId: 2, license: "dssd") { name type } }mutation { addPet(pet: { id: 99 ownerId: 1 name: "Mooo" type: DOG age: 10 license: "555555" }) { ...on Dog { name type } } }query{ pets { ...AllKindsOfPet } } fragment AllKindsOfPet on Pet { ...on Dog { type name owner { name } } ...on Bird { type name owner { name } } }query { pets { ...on Bird { name owner { identifier(type: PASSPORT) } } } }Q:
Docsdoesn't work inGraphiQLA: Click
Edit HTTP Headerson right-top and add headerAuthorization