Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Spring Graphql with DGS Framework #1766

Merged
merged 71 commits into from Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
f7d70e6
Initial integration with spring-graphql with an example app.
srinivasankavitha Jun 23, 2023
0961e04
Fixes to get the prototype working after rebase from master.
srinivasankavitha Dec 13, 2023
77bd7ec
Update spring-boot 3.2 for spring-graphql.
srinivasankavitha Dec 13, 2023
22a9bdd
Parse DGS schema locations config and use it as defaults for Spring-G…
paulbakker Dec 14, 2023
325f30e
Set property defaults based on DGS properties
paulbakker Dec 15, 2023
67cb631
Only set PreparsedDocumentProvider if configured
paulbakker Dec 15, 2023
c502c34
Webflux support with spring-graphql
paulbakker Dec 19, 2023
66a82fb
Webflux support with spring-graphql
paulbakker Dec 19, 2023
03c9182
Subscriptions
paulbakker Dec 20, 2023
fda78f9
Provide GraphQLSource directly from DGS
paulbakker Dec 18, 2023
f5d5053
Renaming packages
paulbakker Jan 3, 2024
f27fa6d
Reloadable schema support
paulbakker Jan 4, 2024
70a58c4
cleanup
paulbakker Jan 4, 2024
6c0d4be
Revert changes to DgsSchemaProvider
paulbakker Jan 4, 2024
f30d897
Formatting
paulbakker Jan 4, 2024
6adb176
Package restructure for spring-graphql
paulbakker Jan 4, 2024
0e71340
Revert changes to DgsDataLoa
paulbakker Jan 4, 2024
7c16b43
format
paulbakker Jan 4, 2024
3f7ca46
Merge remote-tracking branch 'origin/master' into spring-graphql-refa…
paulbakker Jan 4, 2024
a3d8bd1
Add a bridge for spring-graphql's ConnectionTypeDefinitionConfigurer …
srinivasankavitha Jan 11, 2024
1024e3a
improved logging for DgsGraphQLSourceBuilder
paulbakker Jan 11, 2024
5e9c690
Removed obsolete call to ConnectionTypeDefinitionConfigurer
paulbakker Jan 11, 2024
d9abd24
Inject schema resources from spring-graphql into DgsSchemaProvider. (…
srinivasankavitha Jan 15, 2024
e67d853
Add multipart file integration for the example.
srinivasankavitha Jan 18, 2024
538a9b2
Update multipart file reactive datafetcher example.
srinivasankavitha Jan 18, 2024
0fab3aa
update file upload data fetcher and add multipart dependency to react…
srinivasankavitha Jan 18, 2024
72cca17
Conditionally disable DGS Upload scalar registration if using spring-…
srinivasankavitha Jan 19, 2024
f2f6117
Refactor DgsGraphQlSourceBuilder to use AbstractGraphQlSourceBuilder.
srinivasankavitha Jan 20, 2024
4205dc9
Make SchemaProvider return a wrapper type so that we can return runti…
paulbakker Jan 22, 2024
90586a3
Remove now obsolete copy of ContextDataFetcherDecorator
paulbakker Jan 23, 2024
c3efa20
Use published snapshots of spring-graphql in build
paulbakker Jan 23, 2024
7cff840
Split spring-graphql auto configuration
paulbakker Jan 23, 2024
764db48
Enable SchemaMappingInspector.
srinivasankavitha Jan 23, 2024
751d337
Support Spring-GraphQL exception handler resolvers
paulbakker Jan 24, 2024
54ecdb3
Fix build error.
srinivasankavitha Jan 25, 2024
9a2bf99
Merge remote-tracking branch 'origin/master' into spring-graphql-refa…
srinivasankavitha Jan 25, 2024
cea8ffd
Merge latest from master.
srinivasankavitha Jan 25, 2024
fe8283f
@ConditionalOnClass ServerRequest for ReactiveQueryExecutor
paulbakker Feb 1, 2024
3d7cde9
Use PreparsedDocumentProvider if available
paulbakker Feb 1, 2024
f450205
Integrate SchemaReporting functionality from spring-graphql for DGS.
srinivasankavitha Feb 5, 2024
88c9e85
Refactored code for readability.
srinivasankavitha Feb 6, 2024
d95751d
Inject ExecutionGraphQlService instead of DefaultExecutionGraphQlService
paulbakker Feb 27, 2024
b87b000
Add tests using mockmvs and GraphQlTester from Spring-GraphQL for exa…
srinivasankavitha Feb 27, 2024
0f06c62
Fix set up of subscription test with GraphQlTester.
srinivasankavitha Feb 28, 2024
16610a0
Fix classname of HttpTestSliceWithGraphQlTesterTest
paulbakker Feb 28, 2024
738653d
Set up a test using vanilla GraphQlTester as a substitute for query e…
srinivasankavitha Feb 28, 2024
1f5bae0
Merge branch 'spring-graphql-refactored' of github.com:Netflix/dgs-fr…
srinivasankavitha Feb 28, 2024
372ceac
Disable test.
srinivasankavitha Feb 28, 2024
8e3ce55
Fix set up of tester in GreetingTestWithGraphQlTester.
srinivasankavitha Feb 29, 2024
181fac9
Disable GreetingTestWithGraphQlTester
srinivasankavitha Feb 29, 2024
db7a3b0
Add persisted queries tests - disabled since they don't work.
srinivasankavitha Mar 1, 2024
5b64a3a
Test beans created by Dgs/Spring-GraphQl autoconfiguration
paulbakker Mar 4, 2024
6aba494
SmokeTest for DGS/SpringGraphQL integration
paulbakker Mar 5, 2024
20a6b4f
Rename tests and add a test using Dgs Test Slice with MockMvc and Htt…
srinivasankavitha Mar 5, 2024
a550bc4
Added mockmvc example test
paulbakker Mar 6, 2024
cb72423
Merge remote-tracking branch 'origin/master' into spring-graphql-refa…
srinivasankavitha Mar 6, 2024
e8db2c4
Formatting fixes.
srinivasankavitha Mar 6, 2024
23ab47f
Add @EnableDgsTest and @EnableDgsMockMvcTest test slices, and updated…
paulbakker Mar 6, 2024
a1775b2
Add Spring graphql style data loader example.
srinivasankavitha Mar 8, 2024
359df0f
Merge branch 'spring-graphql-refactored' of github.com:Netflix/dgs-fr…
srinivasankavitha Mar 8, 2024
0bcd4fa
Update to use 1.2.6-SNAPSHOT of spring-graphql.
srinivasankavitha Mar 9, 2024
53cb73f
Allow execution strategy for query and mutation to be overrideable be…
srinivasankavitha Mar 13, 2024
31f927f
Add a .block() in the graphql interceptor to force non-async dispatch
paulbakker Mar 19, 2024
80fc057
Merge remote-tracking branch 'origin/spring-graphql-refactored' into …
paulbakker Mar 19, 2024
7affc82
Remove unused QueryValueCustomizer from DgsWebMvcGraphQLInterceptor
paulbakker Mar 20, 2024
dc0f6ae
Added property to enable/disable async dispatch
paulbakker Mar 21, 2024
2421ca0
Fix tests for persisted queries, works now with latest snapshot 1.2.6…
srinivasankavitha Mar 25, 2024
6ae852a
Merge remote-tracking branch 'origin/master' into spring-graphql-refa…
paulbakker Mar 28, 2024
d7818f0
Added property to enable/disable async dispatch
paulbakker Mar 28, 2024
e74eeea
Merge remote-tracking branch 'origin/spring-graphql-refactored' into …
paulbakker Mar 28, 2024
73922d1
lint fix
paulbakker Mar 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 0 additions & 6 deletions graphql-dgs-example-java-webflux/dependencies.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -44,7 +44,7 @@ void withHeaders() {
MockHttpServletRequest servletRequest = new MockHttpServletRequest();
servletRequest.addHeader("demo-header", "demo-header-value");

String message = queryExecutor.executeAndExtractJsonPath("{headers}", "data.headers", new ServletWebRequest(servletRequest));
String message = queryExecutor.executeAndExtractJsonPath("{demoHeader}", "data.demoHeader", new ServletWebRequest(servletRequest));
assertThat(message).isEqualTo("demo-header-value");
}

Expand All @@ -53,7 +53,7 @@ void withHeadersAndNoRequest() {
HttpHeaders headers = new HttpHeaders();
headers.add("demo-header", "demo-header-value");

String message = queryExecutor.executeAndExtractJsonPath("{headers}", "data.headers", headers);
String message = queryExecutor.executeAndExtractJsonPath("{demoHeader}", "data.demoHeader", headers);
assertThat(message).isEqualTo("demo-header-value");
}
}
Expand Up @@ -25,8 +25,6 @@
import graphql.relay.SimpleListConnection;
import graphql.schema.DataFetchingEnvironment;
import org.dataloader.DataLoader;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.RequestHeader;

import java.util.ArrayList;
import java.util.Collections;
Expand Down
Expand Up @@ -28,7 +28,14 @@

@DgsComponent
public class RequestHeadersDataFetcher {

@DgsData(parentType = "Query", field = "headers")
public String headers(DgsDataFetchingEnvironment dfe) {
HttpHeaders headers = dfe.getDgsContext().getRequestData().getHeaders();
return headers.toString();
}

@DgsData(parentType = "Query", field = "demoHeader")
public String headers(DgsDataFetchingEnvironment dfe, @RequestHeader("demo-header") String demoHeader) {
return demoHeader;
}
Expand Down
Expand Up @@ -25,6 +25,7 @@ type Query {

headers: String
referer: String
demoHeader: String

### To show how to handle HttpHeaders
helloWithHeaders(name: String): String
Expand Down Expand Up @@ -95,3 +96,5 @@ type Stock {
scalar Upload
scalar LocalTime

directive @connection on OBJECT

@@ -0,0 +1,35 @@
/*
* Copyright 2024 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.netflix.graphql.dgs.pagination

import org.springframework.boot.SpringApplication
import org.springframework.boot.env.EnvironmentPostProcessor
import org.springframework.core.env.ConfigurableEnvironment
import org.springframework.core.env.MapPropertySource

class DgsPaginationEnvironmentPostProcessor : EnvironmentPostProcessor {
override fun postProcessEnvironment(environment: ConfigurableEnvironment, application: SpringApplication) {
val properties = mutableMapOf<String, Any>()
properties["dgs.springgraphql.pagination.enabled"] = false
environment.propertySources.addLast(
MapPropertySource(
"dgs-pagination-defaults",
properties
)
)
}
}
@@ -0,0 +1 @@
org.springframework.boot.env.EnvironmentPostProcessor=com.netflix.graphql.dgs.pagination.DgsPaginationEnvironmentPostProcessor
5 changes: 3 additions & 2 deletions graphql-dgs-reactive/build.gradle.kts
Expand Up @@ -16,8 +16,9 @@

dependencies {
api(project(":graphql-dgs"))
implementation("org.springframework.boot:spring-boot-starter")
implementation("org.springframework:spring-webflux")
compileOnly("org.springframework.boot:spring-boot-starter")
compileOnly("org.springframework:spring-webflux")

implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")
implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
Expand Down
18 changes: 0 additions & 18 deletions graphql-dgs-reactive/dependencies.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -101,6 +101,7 @@ open class DgsAutoConfiguration(
}

@Bean
@ConditionalOnMissingBean
open fun dgsQueryExecutor(
applicationContext: ApplicationContext,
schema: GraphQLSchema,
Expand Down
42 changes: 42 additions & 0 deletions graphql-dgs-spring-graphql-example-java-webflux/.gitignore
@@ -0,0 +1,42 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
8 changes: 8 additions & 0 deletions graphql-dgs-spring-graphql-example-java-webflux/README.md
@@ -0,0 +1,8 @@
This example app demonstrates some DGS framework features.
It also includes a very simple React UI that uses Apollo Client that connects to both the /graphql and /subscriptions endpoints.
Start the app by running the `ExampleApp` class (e.g. from an IDE).

* Graphiql will be available on: http://localhost:8080/graphiql
* The example UI will be available on: http://localhost:8080/index.html

The example project includes a number of tests as well.
31 changes: 31 additions & 0 deletions graphql-dgs-spring-graphql-example-java-webflux/build.gradle.kts
@@ -0,0 +1,31 @@
/*
* Copyright 2021 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

dependencies {

implementation(project(":graphql-dgs-example-shared"))
implementation(project(":graphql-dgs-pagination"))
implementation(project(":graphql-dgs-reactive"))
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation(project(":graphql-dgs-spring-graphql-starter"))
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation(project(":graphql-dgs-spring-boot-micrometer"))
implementation("com.github.ben-manes.caffeine:caffeine")

testImplementation("org.springframework.boot:spring-boot-starter-webflux")
testImplementation(project(":graphql-dgs-client"))
testImplementation("io.projectreactor:reactor-test")
}