Commit Graph

87 Commits

Author SHA1 Message Date
Brian Clozel
2ebbd464b8 Fix configuration metadata generation
This commit fixes the build configuration for annotation processing.
The configuration metadata is now being generated and packaged with the
starter module.

Fixes gh-33
2021-02-02 15:43:24 +01:00
Brian Clozel
36121f338f Enable WebSocket endpoint with config property
Prior to this commit, the WebSocket endpoint (MVC or WebFlux) would be
enabled by default. In the case of MVC, the presence of
`spring-websocket` and the required dependencies was an additional hint
that could enable/disable this support depending on the application.

This commit changes the websocket path configuration so that it doesn't
hold a default value anymore. Configuring this property will trigger the
WebSocket support.

Right now developers cannot configure it to be the same as the
`spring.graphql.path`, but this will be solved in #30.

This commit also revisits the configuration properties namespace for
clarity, moving the websocket bits under their own section.

Closes gh-31
2021-02-02 15:27:00 +01:00
Brian Clozel
5696b8cead Configure WebInterceptors in handlers
This commit gathers `WebInterceptor` beans from the context (in an
ordered fashion) and configures them on the relevant GraphQL handlers.

Closes gh-7
2021-02-02 13:53:53 +01:00
Brian Clozel
2990df6c43 Guard MVC auto-configuration with WebSocket classes
This commit ensures that the WebSocket auto-configuration is guarded
with class conditions on WebSocket classes (from the javax API and the
spring-websocket artifact).

This prevents issues where application without such dependencies are
failing at startup.
2021-02-02 10:03:43 +01:00
Rossen Stoyanchev
abad0e1b80 Update graphql-spring-boot-starter test dependencies 2021-02-02 08:08:52 +00:00
Andreas Marek
6440b8b0c9 Upgrade GraphQL Java to 16.2
Closes gh-29
2021-02-02 08:08:52 +00:00
Rossen Stoyanchev
2f52e35050 Support for subscriptions with WebMvc and spring-websocket 2021-02-01 22:38:52 +00:00
Rossen Stoyanchev
63dc81c922 Polishing and minor fix to remove Subscription 2021-02-01 22:17:27 +00:00
Rossen Stoyanchev
49c5caf71d Add rejection for apollographql/subscriptions-transport-ws 2021-01-19 21:17:02 +00:00
Rossen Stoyanchev
c82171897e Polishing 2021-01-19 21:15:22 +00:00
Andreas Marek
19f2693bdf schema is not needed if the top level types are named Query/Mutation/Subscription 2021-01-19 07:36:59 +00:00
Andreas Marek
5ccacd1bb4 use the more idiomatic Query type instead QueryType 2021-01-18 21:35:36 +00:00
Rossen Stoyanchev
ef33e5ea52 Minor refactoring in WebSocketMessageInput
Decouple from HandshakeInfo which is WebFlux specific.
Rename the class to WebSocketMessageInput since it's per message.
Use more specific name for id field based on the protocol.
2021-01-18 21:33:10 +00:00
Rossen Stoyanchev
5a77b93671 Minor refactoring in GraphQLWebSocketHandler
The subscriptions map is now per session and not global.
The rest is polishing.
Minor refactoring
2021-01-18 21:33:10 +00:00
Andreas Marek
b1a11973c4 upgrade to graphql java 16.1
Closes gh-25
2021-01-18 08:37:13 +00:00
Rossen Stoyanchev
bbb0d98511 Complete fix for "connection_init" not having id
Closes gh-27
2021-01-17 22:05:33 +00:00
Andreas Marek
edcd801c8c id is not required on every message (notably init) 2021-01-17 09:38:40 +11:00
Brian Clozel
633ee1a1b5 Refactor project structure
This commit refactors the project structure to regroup GraphQL web
support under the spring-graphql-web module, and move all the Spring
Boot support classes under a single graphql-spring-boot-starter one.

Right now, the starter module contains everything: classes for MVC,
WebFlux and Actuator support as well as required dependencies. We will
change that in the future.
2021-01-05 16:35:34 +01:00
Brian Clozel
3e8027a0ca Upgrade to Spring Boot 2.4.1 2021-01-05 13:12:47 +01:00
Brian Clozel
c6d75f57d7 Load GraphQL schema as a Resource 2021-01-05 11:20:05 +01:00
Rossen Stoyanchev
63065d4e8e Create webflux and webmvc sub-packages under ~.graphql
Allows simpler and consistent names for HTTP and WebSocket handler
classes for webmvc and webflux.
2021-01-03 21:40:23 +00:00
Rossen Stoyanchev
35c2068bdf Rename webmvc-http-endpoint to webmvc-http 2021-01-03 21:40:23 +00:00
Rossen Stoyanchev
2e32a06a55 Update to latest GraphQL over WebSocket protocol 2021-01-03 21:40:19 +00:00
Rossen Stoyanchev
bb9d1dc300 Extract WebSocketHandler to top-level class 2021-01-03 21:38:08 +00:00
Rossen Stoyanchev
eda2bd3f33 Rename graphql-sample to webmvc-http-endpoint 2021-01-03 21:37:43 +00:00
Rossen Stoyanchev
099733c1f0 Create top-level samples directory 2021-01-03 21:37:26 +00:00
Rossen Stoyanchev
fd9151adec Add logging in GraphQL handlers 2020-11-29 18:53:33 +00:00
Rossen Stoyanchev
b10d5f7df7 Add support for subscriptions over WebSocket in WebFlux 2020-11-29 18:53:05 +00:00
Rossen Stoyanchev
1dc38c8323 Avoided repeated Resource resolution of graphiql page 2020-11-16 21:46:35 +00:00
Brian Clozel
41333b6c3e Add documentation to README
This commit adds some documentation to the README file:

* getting started with this project
* core auto-configuration
* metrics support
2020-11-13 16:14:52 +01:00
Brian Clozel
e290e426ee The CI image build should be completely non-interactive.
See gh-18
2020-11-13 13:09:07 +01:00
Brian Clozel
c78f05626a Add graphQL sample application
This commit adds a sample application to the repository.
This application should not be published as part of the build.

In this application, we're trying to showcase the various features and
use cases with our Spring graphQL integration. We're mixing here data
fetchers backed by datastores or remote hypermedia APIs.

Closes gh-15
2020-11-13 11:52:30 +01:00
Brian Clozel
f711dad1b6 Introduce GraphiQL integration
This commit adds a very simple graphiQL integration: we're shipping the
project with a sample graphiQL `index.html` page that's relying on CDNs
to display the explorer.
We're also plugging in that resource at the graphQL endpoint location,
responding to GET requests. This is not a problem since for now we're
only considering POST requests to the endpoint for actual queries.

Closes gh-12
2020-11-13 11:52:13 +01:00
Brian Clozel
ce8ac6fc54 Fix null variables in WebInput
The graphQL spec requires that the `variables` object should not be
null. Prior to this commit, the `Map#getOrDefault` call would not
prevent that since it returns the value associated with the key, if
defined, or the default value. In our case the key is defined but the
value is null.
2020-11-13 11:52:09 +01:00
Brian Clozel
96d26b4dec Polish 2020-11-13 11:52:04 +01:00
Brian Clozel
43ba3e8fcd Remove GraphQL web starters
The GraphQL Spring Boot starters aren't actually necessary.
The typical GraphQL usage is really tied to the type of web application
you're building: Spring MVC or WebFlux.

Adding the `spring-graphql-web` dependency to the classpath is a signal
strong enough that we can configure additional endpoints into the web
application.

Closes gh-17
2020-11-13 11:51:49 +01:00
Brian Clozel
59d75a948e Add initial Metrics support
This commit provides an initial instrumentation for metrics support
with micrometer. The graphQL `SimpleInstrumentation` is used to
intercept query execution and collect execution time as well as specific
tags.

The set and names of metrics and tags are temporary and we should refine
this infrastructure.

Closes gh-16
2020-11-13 11:51:33 +01:00
Brian Clozel
15de06d33a Add Concourse CI pipeline
This commit adds the Concourse CI pipeline configuration.
The CI build is hosted on https://ci.spring.io.

As an experimental project, artifacts are published for now using the
org.springframework.experimental groupId.

Closes gh-18
2020-11-13 11:51:14 +01:00
Brian Clozel
8a1bf9c388 Fix published POMs
This commit removes the dependencyManagement section from the published
POMs and aligns the starter dependencies with the official ones.
2020-11-13 11:51:09 +01:00
Brian Clozel
1ff1d354e0 Upgrade to Gradle 6.7 2020-11-13 11:50:59 +01:00
Brian Clozel
d7f3aa6fa9 Add Spring Milestone repository to build 2020-10-14 09:38:35 +02:00
Brian Clozel
18f44efe6d Rename and document GraphQL properties 2020-10-13 18:15:20 +02:00
Brian Clozel
22cdc3a28f Add missing package-info 2020-10-13 18:05:08 +02:00
Brian Clozel
95bfe2e318 Support programmatic GraphQLSchema creation
Prior to this commit, the `GraphQLAutoConfiguration` would only consider
the case where the GraphQL schema is read as an SDL from a configured
location.

GraphQL also supports the programmatic creation of the schema and this
case needs to be supported by the auto-configuration.

This commit updates the auto-configuration to disable the schema
creation from the SDL if a `GraphQL.Builder` bean is already contributed
by the application.

Fixes gh-4
2020-10-13 16:16:35 +02:00
Andreas Marek
d22d9c41a9 Restrict content to application json
Closes gh-8
2020-10-13 10:18:18 +02:00
Andreas Marek
d0324b8344 Make url configurable and set default to /graphql
Closes gh-9
2020-10-13 09:59:14 +02:00
Rossen Stoyanchev
7eafec25e3 Support for response headers through WebOutput
See gh-6
2020-10-07 21:36:34 +01:00
Rossen Stoyanchev
d4b9c4750d Polishing WebOutput
See gh-6
2020-10-07 21:13:20 +01:00
Rossen Stoyanchev
cf1e3ce0da Upgrade to Spring Boot 2.4 snapshots
in order to make use of a recent change for WebMvc.fn in
Spring Framework 5.3.

See gh-6
2020-10-07 20:13:34 +01:00
Rossen Stoyanchev
b5d4fe18ab Javadoc updates and rename WebInterceptorExecution 2020-09-28 11:18:42 +01:00