Commit Graph

190 Commits

Author SHA1 Message Date
Brian Clozel
fdf446f3e6 Load multiple GraphQL schema files
Prior to this commit, the `spring.graphql.schema.location` would only
allow a single file as the source for the GraphQL schema.

This commit changes this configuration to
`spring.graphql.schema.locations` so that it accepts actual locations
(folders) and scans for `*.graphqls` files in those locations. All files
are parsed and merged as a single GraphQL `TypeDefinitionRegistry`.

Closes gh-56
2021-06-29 21:27:18 +02:00
Brian Clozel
f29c5ba764 Fix metadata in published artifacts 2021-06-29 16:39:43 +02:00
Brian Clozel
6dd5595f1e Add Milestone releases CI pipeline 2021-06-29 16:34:14 +02:00
Rossen Stoyanchev
bbf152a32f Deserialize errorType from extensions
The errorType field on GraphQLError is specific to GraphQL Java and when
serialized via GraphqlErrorHelper#toSpecification it becomes an
extension with the key "classification".

This commit ensures that we correctly deserialize back to errorType from
the "classification" extension but unfortunately that's limited to the
ErrorClassification enums that we know of.
2021-06-29 14:53:50 +01:00
Brian Clozel
71ce400e4f Upgrade CI pipeline and images 2021-06-29 15:40:51 +02:00
Rossen Stoyanchev
46221c6d17 Adjust mock expectations for QuerydslDataFetcher
See gh-71
2021-06-29 14:33:00 +01:00
Brian Clozel
eef61843d3 Add property for GraphiQL UI path
This commit adds a new `spring.graphql.graphiql.path` configuration
property for setting the path to the GraphiQL UI page.

This change requires updates in the static HTML page to link the
JavaScript fetcher back to the actual GraphQL API endpoint.

Closes gh-70
2021-06-29 13:52:08 +02:00
Rossen Stoyanchev
9a4da366aa Use fallback default predicate for QuerydslDataFetcher
Closes gh-71
2021-06-29 11:52:09 +01:00
Rob Winch
dfebb6f53d webmvc-http-security uses WebGraphQlTester
Issue gh-58
2021-06-28 15:40:45 -05:00
Rob Winch
7d854dbf47 Add webmvc-http-security
Closes gh-58
2021-06-28 14:17:16 -05:00
Rossen Stoyanchev
5822f7d357 Add @Nullable to TestGraphQlError 2021-06-27 21:51:05 +01:00
Rossen Stoyanchev
0b71596aa5 Global error filter in GraphQlTester.Builder
See gh-66
2021-06-27 21:50:37 +01:00
Rossen Stoyanchev
5cd1e266b4 Parameterize GraphQlTester.RequestSpec
This ensures that the order in which inputs are provided, i.e. whether
taken from the base RequestSpec or the Web subtype doesn't matter.

See gh-64
2021-06-27 21:50:00 +01:00
Rossen Stoyanchev
56ccaf685b GraphQlTester and WebGraphQlTester builders
Closes gh-66
2021-06-27 21:49:40 +01:00
Rossen Stoyanchev
4a6c718394 WebGraphQlTester supports HTTP header input
Closes gh-64
2021-06-26 17:48:30 +01:00
Rossen Stoyanchev
410948bde3 Undo more auto-formatting changes 2021-06-26 17:48:00 +01:00
Rossen Stoyanchev
ed767d1a70 Polishing webflux-security 2021-06-26 05:16:45 +01:00
Rossen Stoyanchev
de234c94c4 Decouple GraphQlTester from Web details
Closes gh-65
2021-06-26 05:16:35 +01:00
Rossen Stoyanchev
17bf9ee287 Polishing
Closes gh-59
2021-06-24 21:13:14 +01:00
Mark Paluch
2d53fdc73f Spring Data repositories that support Querydsl
Spring Data repositories that support Querydsl are now supported
as DataFetchers returning single objects and iterables including
projection support.

See gh-59
2021-06-24 21:13:14 +01:00
Rossen Stoyanchev
ab99dc2892 Improve ThreadLocal value handling
ThreadLocal values from a Servlet container thread maybe end up being
unnecessarily restored, e.g. if DataFetcher is invoked on the same
thread and then also removed, which then impacts the filter chain.

The ContextManager now saves the thread id when values are extracted
and ignores restore or remove calls if still on the same thread. This
should also be more optimal, avoiding ThreadLocal access if threads
aren't switched.

See gh-58
2021-06-24 17:15:19 +01:00
Rob Winch
52572c91b0 SecurityDataFetcherExceptionResolver.setAuthenticationTrustResolver 2021-06-22 15:33:04 -05:00
Rob Winch
4aed51438a SecurityDataFetcherExceptionResolver handles AuthenticationException
This is unlikely to happen as authentication happens prior to reaching
the GraphQL APIs. However, a user may decide to implement security within
GraphQL as it is possible to do through a Spring Controller.
2021-06-22 15:32:38 -05:00
Rossen Stoyanchev
cedb5fb40d Apply context to all exception resolvers
This is more consistent with DataFetcher's, it less brittle, and a
no-op where there is no ThreadLocal context.
2021-06-18 18:34:03 +01:00
Rossen Stoyanchev
efa585b887 Refine and clarify contracts for context management
Use ThreadLocalAccessor, the main API for ThreadLocal value management,
to state where this is supported, which is in Spring MVC, GraphQL
applications.

Improve Javadoc in related contracts as well including a minor
refactoring in ContextManager.
2021-06-18 18:07:05 +01:00
Brian Clozel
57fb7c59f5 Fix build and disable jjavaformat + checkstyle
Right now the Spring JavaFormat and Checkstyle arrangement doesn't work
for the Spring GraphQL source code.

This commit disables the dedicated Gradle conventions until we find a
better solution.
2021-06-16 12:13:35 +02:00
Rossen Stoyanchev
0ce48dc978 Turn off auto-formatting in Boot starter tests 2021-06-16 10:59:28 +01:00
Brian Clozel
16209d8d56 Merge pull request #57 from schauder/fix-schema-location
Correct location of schema in README.
2021-06-16 11:58:58 +02:00
Jens Schauder
ec9f3dd310 Correct location of schema in README. 2021-06-16 11:22:19 +02:00
Rossen Stoyanchev
43f9e34c81 Turn off auto-formatting where it reduces readability 2021-06-15 14:01:52 +01:00
Rossen Stoyanchev
a5f56ca3cb Update README.md 2021-06-09 19:33:11 +01:00
Rob Winch
b276a39902 Add SecurityDataFetcherExceptionResolver 2021-06-09 08:54:52 -05:00
Rob Winch
0db7ee2be3 Merge pull request #55 from rwinch/webflux-security
Add WebFlux Security Sample
2021-06-08 14:31:34 -05:00
Rob Winch
17a56a1000 Use New Lamda Security Syntax 2021-06-02 17:05:52 -05:00
Rob Winch
d139e97cdb Rename to SampleApplication
Follow convention of other sample applications.
2021-06-02 16:41:35 -05:00
Rob Winch
9a61207f2d Remove DataFetchers
Follow the conventions of the other sample projects.
2021-06-02 16:40:55 -05:00
Rob Winch
16f2baa263 Format webflux-security 2021-06-02 16:36:10 -05:00
Rob Winch
96d25b2a91 employee-service -> webflux-security 2021-06-02 13:36:40 -05:00
Rob Winch
05098fd5d1 Update to Spring Boot 2.5.0 2021-06-02 13:29:22 -05:00
Rob Winch
d3a0fa1c4f schema.graphqls->/graphql/schema.graphqls 2021-06-02 11:31:44 -05:00
Rob Winch
9b4c053a30 invalidCredentials 2021-06-02 11:31:44 -05:00
Rob Winch
ca369ecc7c salaryDataFetcher returns Mono
We need the return type to be a Reactor type for the context to be
propagated.
2021-06-02 11:31:44 -05:00
Rob Winch
84b9b65777 Use headers instead of WithMockUser
This ensures that we don't get false positives when the Reactor return
types are not continuous.
2021-06-02 11:31:44 -05:00
Rob Winch
4b44f7a987 Use ADMIN role 2021-06-02 11:31:44 -05:00
Andreas Marek
2edc4c585a add employee service example 2021-06-02 11:31:44 -05:00
Brian Clozel
f8b2ad552f Refactor project build
This commit refactors the project build to better share dependency
management definitions between modules.

This also upgrades the project to Spring Boot 2.5.0.

Closes gh-45
2021-06-02 15:45:51 +02:00
Brian Clozel
53e2a379de Reformat sample applications
Fixes gh-54
2021-06-02 14:30:00 +02:00
Brian Clozel
39937679e3 Apply Spring JavaFormat to Spring GraphQL Test
See gh-54
2021-06-02 14:30:00 +02:00
Brian Clozel
d048c2e4fe Apply Spring JavaFormat to Spring GraphQL
See gh-54
2021-06-02 14:30:00 +02:00
Brian Clozel
f8b90b592d Apply Spring JavaFormat to Spring GraphQL Boot starter
This commit applies the build conventions to the Spring Boot GraphQL
starter module and fixes all formatting issues.

See gh-54
2021-06-02 14:30:00 +02:00