GraphQL Java + SpringBoot + WebFlux evaluation. Prove of concept of a declarative, annotations based configuration (see GraphQLHandler)
To start the application localy, run in the project's root folder:
./gradlew bootRun
To start it on Docker:
./gradlew clean bootJar
docker build -t graphql-library examples/library
docker run -d --rm -p 8080:8080 graphql-library
The application exposes single GraphQL endpoint on http://localhost:8080/graphql
GraphQL schema: schema.graphqls
GraphQL:
query listBooks {
books {
id,
title,
authors {
id,
name
}
}
}
Curl:
curl --request POST \
--url http://localhost:8080/graphql \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{"query":"query listBooks {books {id, title, authors {id, name}}}"}'
GraphQL:
query listAuthors {
authors {
id,
name,
books {
id,
title
}
}
}
Curl:
curl --request POST \
--url http://localhost:8080/graphql \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{"query":"query listAuthors {authors {id, name, books {id, title}}}"}'
GraphQL:
mutation createBook {
addBook(authorIds: ["1"], title: "New book") {
id
}
}
Curl:
curl --request POST \
--url http://localhost:8080/graphql \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{"query":"mutation createBook {addBook(authorIds: [\"1\"], title: \"New book\") {id}}"}'
GraphQL:
mutation removeBook {
removeBook(id: "1")
}
Curl:
curl --request POST \
--url http://localhost:8080/graphql \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{"query":"mutation removeBook {removeBook(id: \"1\")}"}'
GraphQL:
subscription events {
events
}
Curl:
curl -N --request POST \
--url http://localhost:8080/graphql \
--header 'accept: text/event-stream' \
--header 'content-type: application/json' \
--data '{"query":"subscription events {events}"}'