├── .github ├── actions │ ├── await-http-resource │ │ └── action.yml │ ├── build-and-publish │ │ └── action.yml │ ├── create-github-release │ │ ├── action.yml │ │ └── changelog-generator.yml │ ├── prepare-gradle-build │ │ └── action.yml │ ├── send-notification │ │ └── action.yml │ └── sync-to-maven-central │ │ ├── action.yml │ │ └── artifacts.spec ├── dco.yml └── workflows │ ├── backport-bot.yml │ ├── build-and-deploy-snapshot.yml │ ├── ci.yml │ ├── delete-staged-release.yml │ ├── deploy-docs.yml │ ├── release-milestone.yml │ ├── release.yml │ └── update-antora-ui-spring.yml ├── .gitignore ├── .idea └── icon.svg ├── .sdkmanrc ├── CODE_OF_CONDUCT.adoc ├── LICENSE.txt ├── README.md ├── build.gradle ├── buildSrc ├── build.gradle ├── gradle.properties ├── settings.gradle └── src │ └── main │ └── java │ └── org │ └── springframework │ └── graphql │ └── build │ ├── ConventionsPlugin.java │ ├── architecture │ ├── ArchitectureCheck.java │ ├── ArchitecturePlugin.java │ └── ArchitectureRules.java │ └── conventions │ ├── DeploymentConventions.java │ ├── FormattingConventions.java │ ├── JavaConventions.java │ └── KotlinConventions.java ├── gradle.properties ├── gradle ├── publishing.gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── platform └── build.gradle ├── settings.gradle ├── spring-graphql-docs ├── .github │ └── workflows │ │ └── deploy-docs.yml ├── antora-playbook.yml ├── antora.yml ├── build.gradle ├── modules │ └── ROOT │ │ ├── examples │ │ └── docs-src │ │ ├── nav.adoc │ │ └── pages │ │ ├── boot-starter.adoc │ │ ├── client.adoc │ │ ├── codegen.adoc │ │ ├── controllers.adoc │ │ ├── data.adoc │ │ ├── federation.adoc │ │ ├── graalvm-native.adoc │ │ ├── graphiql.adoc │ │ ├── index.adoc │ │ ├── observability.adoc │ │ ├── request-execution.adoc │ │ ├── samples.adoc │ │ ├── security.adoc │ │ ├── standalone-setup.adoc │ │ ├── testing.adoc │ │ └── transports.adoc ├── package.json └── src │ ├── docs │ ├── asciidoc │ │ ├── anchor-rewrite.properties │ │ └── css │ │ │ └── stylesheet.css │ └── spring-graphql.svg │ └── main │ ├── java │ └── org │ │ └── springframework │ │ └── graphql │ │ └── docs │ │ ├── client │ │ ├── httpgraphqlclient │ │ │ └── ClientUsage.java │ │ ├── httpsyncgraphqlclient │ │ │ └── SyncClientUsage.java │ │ ├── interception │ │ │ ├── MyInterceptor.java │ │ │ ├── SyncInterceptor.java │ │ │ └── UseInterceptor.java │ │ ├── requests │ │ │ ├── documentsource │ │ │ │ └── DocumentSource.java │ │ │ ├── execute │ │ │ │ └── Execute.java │ │ │ └── retrieve │ │ │ │ └── Retrieve.java │ │ ├── rsocketgraphqlclient │ │ │ └── RSocketClientUsage.java │ │ ├── subscriptions │ │ │ ├── execute │ │ │ │ └── ExecuteSubscription.java │ │ │ └── retrieve │ │ │ │ └── RetrieveSubscription.java │ │ └── websocketgraphqlclient │ │ │ └── WebSocketClientUsage.java │ │ ├── controllers │ │ ├── exceptionhandler │ │ │ ├── Book.java │ │ │ ├── BookController.java │ │ │ └── GlobalExceptionHandler.java │ │ ├── namespacing │ │ │ ├── Album.java │ │ │ ├── Artist.java │ │ │ ├── MusicController.java │ │ │ └── NamespaceConfiguration.java │ │ └── schemamapping │ │ │ └── localcontext │ │ │ └── LocalContextBookController.java │ │ ├── execution │ │ ├── graphqlsource │ │ │ ├── CustomExecutionIdProvider.java │ │ │ └── GraphQlConfig.java │ │ ├── reactivedatafetcher │ │ │ └── GraphQlConfig.java │ │ └── timeout │ │ │ ├── HttpTimeoutConfiguration.java │ │ │ └── WebGraphQlHandlerTimeout.java │ │ ├── graalvm │ │ ├── client │ │ │ ├── Project.java │ │ │ ├── ProjectService.java │ │ │ └── Releases.java │ │ └── server │ │ │ ├── Book.java │ │ │ ├── BookRepository.java │ │ │ └── GraphQlConfiguration.java │ │ ├── graphiql │ │ └── configuration │ │ │ └── GraphiQlConfiguration.java │ │ ├── server │ │ ├── interception │ │ │ └── web │ │ │ │ ├── Person.java │ │ │ │ ├── RequestErrorInterceptor.java │ │ │ │ ├── RequestHeaderInterceptor.java │ │ │ │ └── ResponseHeaderInterceptor.java │ │ └── transports │ │ │ └── rsocket │ │ │ └── GraphQlRSocketController.java │ │ ├── standalonesetup │ │ └── GraphQlConfiguration.java │ │ └── testing │ │ ├── errors │ │ └── TestErrors.java │ │ ├── graphqlservicetester │ │ └── ServiceSetup.java │ │ ├── httpgraphqltester │ │ └── HttpSetup.java │ │ ├── requests │ │ ├── TesterRequests.java │ │ └── nestedpaths │ │ │ └── NestedPaths.java │ │ ├── rsocketgraphqltester │ │ └── RSocketSetup.java │ │ ├── subscriptions │ │ └── TestSubscriptions.java │ │ ├── webgraphqltester │ │ └── WebSetup.java │ │ └── websocketgraphqltester │ │ └── WsSetup.java │ └── resources │ └── controllers │ └── namespaces.graphqls ├── spring-graphql-test ├── build.gradle └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── springframework │ │ │ └── graphql │ │ │ └── test │ │ │ └── tester │ │ │ ├── AbstractDelegatingGraphQlTester.java │ │ │ ├── AbstractDirectGraphQlTransport.java │ │ │ ├── AbstractGraphQlTesterBuilder.java │ │ │ ├── DefaultExecutionGraphQlServiceTesterBuilder.java │ │ │ ├── DefaultGraphQlTester.java │ │ │ ├── DefaultHttpGraphQlTesterBuilder.java │ │ │ ├── DefaultRSocketGraphQlTesterBuilder.java │ │ │ ├── DefaultTransportGraphQlTesterBuilder.java │ │ │ ├── DefaultWebGraphQlTesterBuilder.java │ │ │ ├── DefaultWebSocketGraphQlTesterBuilder.java │ │ │ ├── EncoderDecoderMappingProvider.java │ │ │ ├── ExecutionGraphQlServiceTester.java │ │ │ ├── GraphQlServiceGraphQlTransport.java │ │ │ ├── GraphQlTester.java │ │ │ ├── HttpGraphQlTester.java │ │ │ ├── JacksonJsonProvider.java │ │ │ ├── JacksonMappingProvider.java │ │ │ ├── RSocketGraphQlTester.java │ │ │ ├── WebGraphQlHandlerGraphQlTransport.java │ │ │ ├── WebGraphQlTester.java │ │ │ ├── WebSocketGraphQlTester.java │ │ │ ├── WebTestClientTransport.java │ │ │ └── package-info.java │ └── resources │ │ └── META-INF │ │ └── native-image │ │ └── org.springframework.graphql │ │ └── spring-graphql │ │ └── resource-config.json │ └── test │ ├── java │ └── org │ │ └── springframework │ │ └── graphql │ │ └── test │ │ └── tester │ │ ├── GraphQlTesterBuilderTests.java │ │ ├── GraphQlTesterTestSupport.java │ │ ├── GraphQlTesterTests.java │ │ ├── MovieCharacter.java │ │ ├── RSocketGraphQlTesterBuilderTests.java │ │ ├── WebGraphQlTesterBuilderTests.java │ │ └── WebSocketGraphQlTesterTests.java │ └── resources │ ├── graphql-test │ ├── friends.graphql │ ├── greeting.graphql │ └── me.graphql │ └── log4j2-test.xml ├── spring-graphql ├── build.gradle └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── springframework │ │ │ └── graphql │ │ │ ├── ExecutionGraphQlRequest.java │ │ │ ├── ExecutionGraphQlResponse.java │ │ │ ├── ExecutionGraphQlService.java │ │ │ ├── GraphQlRequest.java │ │ │ ├── GraphQlResponse.java │ │ │ ├── MediaTypes.java │ │ │ ├── ResponseError.java │ │ │ ├── ResponseField.java │ │ │ ├── client │ │ │ ├── AbstractDelegatingGraphQlClient.java │ │ │ ├── AbstractGraphQlClientBuilder.java │ │ │ ├── AbstractGraphQlClientSyncBuilder.java │ │ │ ├── ClientGraphQlRequest.java │ │ │ ├── ClientGraphQlResponse.java │ │ │ ├── ClientResponseField.java │ │ │ ├── CodecDelegate.java │ │ │ ├── DefaultClientGraphQlRequest.java │ │ │ ├── DefaultClientGraphQlResponse.java │ │ │ ├── DefaultClientResponseField.java │ │ │ ├── DefaultGraphQlClient.java │ │ │ ├── DefaultHttpGraphQlClientBuilder.java │ │ │ ├── DefaultRSocketGraphQlClientBuilder.java │ │ │ ├── DefaultSyncHttpGraphQlClientBuilder.java │ │ │ ├── DefaultTransportGraphQlClientBuilder.java │ │ │ ├── DefaultWebSocketGraphQlClientBuilder.java │ │ │ ├── DgsGraphQlClient.java │ │ │ ├── FieldAccessException.java │ │ │ ├── GraphQlClient.java │ │ │ ├── GraphQlClientException.java │ │ │ ├── GraphQlClientInterceptor.java │ │ │ ├── GraphQlTransport.java │ │ │ ├── GraphQlTransportException.java │ │ │ ├── HttpGraphQlClient.java │ │ │ ├── HttpGraphQlTransport.java │ │ │ ├── HttpMessageConverterDelegate.java │ │ │ ├── HttpSyncGraphQlClient.java │ │ │ ├── HttpSyncGraphQlTransport.java │ │ │ ├── RSocketGraphQlClient.java │ │ │ ├── RSocketGraphQlTransport.java │ │ │ ├── ResponseMapGraphQlResponse.java │ │ │ ├── SubscriptionErrorException.java │ │ │ ├── SyncGraphQlClientInterceptor.java │ │ │ ├── SyncGraphQlTransport.java │ │ │ ├── WebGraphQlClient.java │ │ │ ├── WebSocketDisconnectedException.java │ │ │ ├── WebSocketGraphQlClient.java │ │ │ ├── WebSocketGraphQlClientInterceptor.java │ │ │ ├── WebSocketGraphQlTransport.java │ │ │ └── package-info.java │ │ │ ├── data │ │ │ ├── ArgumentValue.java │ │ │ ├── GraphQlArgumentBinder.java │ │ │ ├── GraphQlRepository.java │ │ │ ├── federation │ │ │ │ ├── EntitiesDataFetcher.java │ │ │ │ ├── EntityArgumentMethodArgumentResolver.java │ │ │ │ ├── EntityArgumentsMethodArgumentResolver.java │ │ │ │ ├── EntityHandlerMethod.java │ │ │ │ ├── EntityMapping.java │ │ │ │ ├── FederationSchemaFactory.java │ │ │ │ ├── RepresentationException.java │ │ │ │ ├── RepresentationNotResolvedException.java │ │ │ │ └── package-info.java │ │ │ ├── method │ │ │ │ ├── HandlerMethod.java │ │ │ │ ├── HandlerMethodArgumentResolver.java │ │ │ │ ├── HandlerMethodArgumentResolverComposite.java │ │ │ │ ├── InvocableHandlerMethodSupport.java │ │ │ │ ├── annotation │ │ │ │ │ ├── Argument.java │ │ │ │ │ ├── Arguments.java │ │ │ │ │ ├── BatchMapping.java │ │ │ │ │ ├── ContextValue.java │ │ │ │ │ ├── GraphQlExceptionHandler.java │ │ │ │ │ ├── LocalContextValue.java │ │ │ │ │ ├── MutationMapping.java │ │ │ │ │ ├── QueryMapping.java │ │ │ │ │ ├── SchemaMapping.java │ │ │ │ │ ├── SubscriptionMapping.java │ │ │ │ │ ├── package-info.java │ │ │ │ │ └── support │ │ │ │ │ │ ├── AnnotatedControllerConfigurer.java │ │ │ │ │ │ ├── AnnotatedControllerDetectionSupport.java │ │ │ │ │ │ ├── AnnotatedControllerExceptionResolver.java │ │ │ │ │ │ ├── ArgumentMethodArgumentResolver.java │ │ │ │ │ │ ├── ArgumentValueValueExtractor.java │ │ │ │ │ │ ├── ArgumentsMethodArgumentResolver.java │ │ │ │ │ │ ├── AuthenticationPrincipalArgumentResolver.java │ │ │ │ │ │ ├── BatchLoaderHandlerMethod.java │ │ │ │ │ │ ├── ContextValueMethodArgumentResolver.java │ │ │ │ │ │ ├── ContinuationHandlerMethodArgumentResolver.java │ │ │ │ │ │ ├── DataFetcherHandlerMethod.java │ │ │ │ │ │ ├── DataFetcherHandlerMethodSupport.java │ │ │ │ │ │ ├── DataFetcherMappingInfo.java │ │ │ │ │ │ ├── DataFetchingEnvironmentMethodArgumentResolver.java │ │ │ │ │ │ ├── DataLoaderMethodArgumentResolver.java │ │ │ │ │ │ ├── HandlerDataFetcherExceptionResolver.java │ │ │ │ │ │ ├── LocalContextValueMethodArgumentResolver.java │ │ │ │ │ │ ├── PrincipalMethodArgumentResolver.java │ │ │ │ │ │ ├── ProjectedPayloadMethodArgumentResolver.java │ │ │ │ │ │ ├── SchemaMappingBeanFactoryInitializationAotProcessor.java │ │ │ │ │ │ ├── ScrollSubrangeMethodArgumentResolver.java │ │ │ │ │ │ ├── SortMethodArgumentResolver.java │ │ │ │ │ │ ├── SourceMethodArgumentResolver.java │ │ │ │ │ │ ├── SubrangeMethodArgumentResolver.java │ │ │ │ │ │ ├── ValidationHelper.java │ │ │ │ │ │ └── package-info.java │ │ │ │ └── package-info.java │ │ │ ├── package-info.java │ │ │ ├── pagination │ │ │ │ ├── Base64CursorEncoder.java │ │ │ │ ├── CompositeConnectionAdapter.java │ │ │ │ ├── ConnectionAdapter.java │ │ │ │ ├── ConnectionAdapterSupport.java │ │ │ │ ├── ConnectionFieldTypeVisitor.java │ │ │ │ ├── CursorEncoder.java │ │ │ │ ├── CursorStrategy.java │ │ │ │ ├── EncodingCursorStrategy.java │ │ │ │ ├── NoOpCursorEncoder.java │ │ │ │ ├── Subrange.java │ │ │ │ └── package-info.java │ │ │ └── query │ │ │ │ ├── AbstractSortStrategy.java │ │ │ │ ├── AutoRegistrationRuntimeWiringConfigurer.java │ │ │ │ ├── JsonKeysetCursorStrategy.java │ │ │ │ ├── PropertySelection.java │ │ │ │ ├── QueryByExampleDataFetcher.java │ │ │ │ ├── QuerydslDataFetcher.java │ │ │ │ ├── RepositoryUtils.java │ │ │ │ ├── ScrollPositionCursorStrategy.java │ │ │ │ ├── ScrollSubrange.java │ │ │ │ ├── SliceConnectionAdapter.java │ │ │ │ ├── SortStrategy.java │ │ │ │ ├── WindowConnectionAdapter.java │ │ │ │ └── package-info.java │ │ │ ├── execution │ │ │ ├── AbstractGraphQlSourceBuilder.java │ │ │ ├── BatchLoaderRegistry.java │ │ │ ├── ClassNameTypeResolver.java │ │ │ ├── CompositeSubscriptionExceptionResolver.java │ │ │ ├── ConnectionTypeDefinitionConfigurer.java │ │ │ ├── ContextDataFetcherDecorator.java │ │ │ ├── ContextPropagationHelper.java │ │ │ ├── ContextSnapshotFactoryHelper.java │ │ │ ├── DataFetcherExceptionResolver.java │ │ │ ├── DataFetcherExceptionResolverAdapter.java │ │ │ ├── DataLoaderRegistrar.java │ │ │ ├── DefaultBatchLoaderRegistry.java │ │ │ ├── DefaultExecutionGraphQlService.java │ │ │ ├── DefaultSchemaResourceGraphQlSourceBuilder.java │ │ │ ├── ErrorType.java │ │ │ ├── ExceptionResolversExceptionHandler.java │ │ │ ├── ExternalSchemaGraphQlSourceBuilder.java │ │ │ ├── GraphQlContextAccessor.java │ │ │ ├── GraphQlSource.java │ │ │ ├── MissingSchemaException.java │ │ │ ├── ReactiveAdapterRegistryHelper.java │ │ │ ├── ReactiveSecurityDataFetcherExceptionResolver.java │ │ │ ├── RuntimeWiringConfigurer.java │ │ │ ├── SchemaMappingInspector.java │ │ │ ├── SchemaReport.java │ │ │ ├── SecurityContextThreadLocalAccessor.java │ │ │ ├── SecurityDataFetcherExceptionResolver.java │ │ │ ├── SecurityExceptionResolverUtils.java │ │ │ ├── SelfDescribingDataFetcher.java │ │ │ ├── SubscriptionExceptionResolver.java │ │ │ ├── SubscriptionExceptionResolverAdapter.java │ │ │ ├── SubscriptionPublisherException.java │ │ │ ├── TypeDefinitionConfigurer.java │ │ │ ├── TypeVisitorHelper.java │ │ │ └── package-info.java │ │ │ ├── observation │ │ │ ├── DataFetcherObservationContext.java │ │ │ ├── DataFetcherObservationConvention.java │ │ │ ├── DataLoaderObservationContext.java │ │ │ ├── DataLoaderObservationConvention.java │ │ │ ├── DefaultDataFetcherObservationConvention.java │ │ │ ├── DefaultDataLoaderObservationConvention.java │ │ │ ├── DefaultExecutionRequestObservationConvention.java │ │ │ ├── ExecutionRequestObservationContext.java │ │ │ ├── ExecutionRequestObservationConvention.java │ │ │ ├── GraphQlObservationDocumentation.java │ │ │ ├── GraphQlObservationInstrumentation.java │ │ │ └── package-info.java │ │ │ ├── package-info.java │ │ │ ├── server │ │ │ ├── DefaultWebGraphQlHandlerBuilder.java │ │ │ ├── GraphQlRSocketHandler.java │ │ │ ├── RSocketGraphQlInterceptor.java │ │ │ ├── RSocketGraphQlRequest.java │ │ │ ├── RSocketGraphQlResponse.java │ │ │ ├── TimeoutWebGraphQlInterceptor.java │ │ │ ├── WebGraphQlHandler.java │ │ │ ├── WebGraphQlInterceptor.java │ │ │ ├── WebGraphQlRequest.java │ │ │ ├── WebGraphQlResponse.java │ │ │ ├── WebSocketGraphQlInterceptor.java │ │ │ ├── WebSocketGraphQlRequest.java │ │ │ ├── WebSocketSessionInfo.java │ │ │ ├── package-info.java │ │ │ ├── support │ │ │ │ ├── AbstractAuthenticationWebSocketInterceptor.java │ │ │ │ ├── AuthenticationExtractor.java │ │ │ │ ├── BearerTokenAuthenticationExtractor.java │ │ │ │ ├── GraphQlWebSocketMessage.java │ │ │ │ ├── GraphQlWebSocketMessageType.java │ │ │ │ ├── SerializableGraphQlRequest.java │ │ │ │ └── package-info.java │ │ │ ├── webflux │ │ │ │ ├── AbstractGraphQlHttpHandler.java │ │ │ │ ├── AuthenticationWebSocketInterceptor.java │ │ │ │ ├── GraphQlHttpHandler.java │ │ │ │ ├── GraphQlRequestPredicates.java │ │ │ │ ├── GraphQlSseHandler.java │ │ │ │ ├── GraphQlWebSocketHandler.java │ │ │ │ ├── GraphiQlHandler.java │ │ │ │ ├── HttpCodecDelegate.java │ │ │ │ ├── SchemaHandler.java │ │ │ │ ├── WebSocketCodecDelegate.java │ │ │ │ └── package-info.java │ │ │ └── webmvc │ │ │ │ ├── AbstractGraphQlHttpHandler.java │ │ │ │ ├── AuthenticationWebSocketInterceptor.java │ │ │ │ ├── GraphQlHttpHandler.java │ │ │ │ ├── GraphQlRequestPredicates.java │ │ │ │ ├── GraphQlSseHandler.java │ │ │ │ ├── GraphQlWebSocketHandler.java │ │ │ │ ├── GraphiQlHandler.java │ │ │ │ ├── SchemaHandler.java │ │ │ │ └── package-info.java │ │ │ └── support │ │ │ ├── AbstractGraphQlResponse.java │ │ │ ├── CachingDocumentSource.java │ │ │ ├── DefaultExecutionGraphQlRequest.java │ │ │ ├── DefaultExecutionGraphQlResponse.java │ │ │ ├── DefaultGraphQlRequest.java │ │ │ ├── DocumentSource.java │ │ │ ├── ResourceDocumentSource.java │ │ │ └── package-info.java │ └── resources │ │ ├── META-INF │ │ ├── native-image │ │ │ └── org.springframework.graphql │ │ │ │ └── spring-graphql │ │ │ │ ├── reflect-config.json │ │ │ │ └── resource-config.json │ │ ├── services │ │ │ ├── io.micrometer.context.ContextAccessor │ │ │ ├── io.micrometer.context.ThreadLocalAccessor │ │ │ └── jakarta.validation.valueextraction.ValueExtractor │ │ └── spring │ │ │ └── aot.factories │ │ └── graphiql │ │ └── index.html │ ├── test │ ├── java │ │ └── org │ │ │ └── springframework │ │ │ └── graphql │ │ │ ├── Author.java │ │ │ ├── Book.java │ │ │ ├── BookCriteria.java │ │ │ ├── BookSource.java │ │ │ ├── DefaultExecutionGraphQlRequestTests.java │ │ │ ├── JacksonJsonProvider.java │ │ │ ├── JacksonMappingProvider.java │ │ │ ├── QAuthor.java │ │ │ ├── ResponseHelper.java │ │ │ ├── TestThreadLocalAccessor.java │ │ │ ├── client │ │ │ ├── DefaultGraphQlClientResponseTests.java │ │ │ ├── GraphQlClientBuilderTests.java │ │ │ ├── GraphQlClientTestSupport.java │ │ │ ├── GraphQlClientTests.java │ │ │ ├── HttpGraphQlClientProtocolTests.java │ │ │ ├── HttpGraphQlTransportIntegrationTests.java │ │ │ ├── HttpSyncGraphQlClientBuilderTests.java │ │ │ ├── MockGraphQlWebSocketServer.java │ │ │ ├── MovieCharacter.java │ │ │ ├── RSocketGraphQlClientBuilderTests.java │ │ │ ├── RSocketGraphQlTransportTests.java │ │ │ ├── WebGraphQlClientBuilderTests.java │ │ │ └── WebSocketGraphQlTransportTests.java │ │ │ ├── data │ │ │ ├── ArgumentValueTests.java │ │ │ ├── GraphQlArgumentBinderTests.java │ │ │ ├── federation │ │ │ │ └── EntityMappingInvocationTests.java │ │ │ ├── method │ │ │ │ └── annotation │ │ │ │ │ └── support │ │ │ │ │ ├── AnnotatedControllerConfigurerInterfaceMappingTests.java │ │ │ │ │ ├── AnnotatedControllerConfigurerTests.java │ │ │ │ │ ├── AnnotatedControllerExceptionResolverTests.java │ │ │ │ │ ├── ArgumentMethodArgumentResolverTests.java │ │ │ │ │ ├── ArgumentResolverTestSupport.java │ │ │ │ │ ├── ArgumentsMethodArgumentResolverTests.java │ │ │ │ │ ├── AuthenticationPrincipalArgumentResolverTests.java │ │ │ │ │ ├── BatchMappingDetectionTests.java │ │ │ │ │ ├── BatchMappingInvocationTests.java │ │ │ │ │ ├── BatchMappingPrincipalMethodArgumentResolverTests.java │ │ │ │ │ ├── BatchMappingTestSupport.java │ │ │ │ │ ├── ContextValueMethodArgumentResolverTests.java │ │ │ │ │ ├── DataFetcherHandlerMethodTests.java │ │ │ │ │ ├── DataFetchingEnvironmentMethodArgumentResolverTests.java │ │ │ │ │ ├── DataLoaderArgumentResolverTests.java │ │ │ │ │ ├── LocalContextValueMethodArgumentResolverTests.java │ │ │ │ │ ├── ProjectedPayloadMethodArgumentResolverTests.java │ │ │ │ │ ├── SchemaMappingBeanFactoryInitializationAotProcessorTests.java │ │ │ │ │ ├── SchemaMappingDetectionTests.java │ │ │ │ │ ├── SchemaMappingInvocationTests.java │ │ │ │ │ ├── SchemaMappingPaginationTests.java │ │ │ │ │ ├── SchemaMappingPrincipalMethodArgumentResolverTests.java │ │ │ │ │ ├── SortMethodArgumentResolverTests.java │ │ │ │ │ ├── SourceMethodArgumentResolverTests.java │ │ │ │ │ ├── SubrangeMethodArgumentResolverTests.java │ │ │ │ │ └── ValidationHelperTests.java │ │ │ ├── pagination │ │ │ │ ├── Base64CursorEncoderTests.java │ │ │ │ └── ConnectionFieldTypeVisitorTests.java │ │ │ └── query │ │ │ │ ├── Book.java │ │ │ │ ├── JsonKeysetCursorStrategyTests.java │ │ │ │ ├── PropertySelectionTests.java │ │ │ │ ├── QBook.java │ │ │ │ ├── QuerydslDataFetcherTests.java │ │ │ │ ├── RepositoryUtilsTests.java │ │ │ │ ├── ScrollPositionCursorStrategyTests.java │ │ │ │ ├── ScrollSubrangeTests.java │ │ │ │ ├── SliceConnectionAdapterTests.java │ │ │ │ ├── WindowConnectionAdapterTests.java │ │ │ │ ├── jpa │ │ │ │ ├── Author.java │ │ │ │ ├── Book.java │ │ │ │ ├── BookJpaRepository.java │ │ │ │ ├── BookProjection.java │ │ │ │ ├── ProjectingBookJpaRepository.java │ │ │ │ └── QueryByExampleDataFetcherJpaTests.java │ │ │ │ ├── mongo │ │ │ │ ├── Author.java │ │ │ │ ├── Book.java │ │ │ │ ├── BookMongoRepository.java │ │ │ │ ├── BookReactiveMongoRepository.java │ │ │ │ ├── QueryByExampleDataFetcherMongoDbTests.java │ │ │ │ └── QueryByExampleDataFetcherReactiveMongoDbTests.java │ │ │ │ └── neo4j │ │ │ │ ├── Author.java │ │ │ │ ├── Book.java │ │ │ │ ├── BookNeo4jRepository.java │ │ │ │ ├── BookReactiveNeo4jRepository.java │ │ │ │ ├── QueryByExampleDataFetcherNeo4jTests.java │ │ │ │ └── QueryByExampleDataFetcherReactiveNeo4jDbTests.java │ │ │ ├── execution │ │ │ ├── BatchLoadingTests.java │ │ │ ├── ClassNameTypeResolverTests.java │ │ │ ├── CompositeSubscriptionExceptionResolverTests.java │ │ │ ├── ConnectionTypeDefinitionConfigurerTests.java │ │ │ ├── ContextDataFetcherDecoratorTests.java │ │ │ ├── DefaultBatchLoaderRegistryTests.java │ │ │ ├── DefaultExecutionGraphQlServiceTests.java │ │ │ ├── DefaultSchemaResourceGraphQlSourceBuilderTests.java │ │ │ ├── ExceptionResolversExceptionHandlerTests.java │ │ │ ├── SchemaMappingInspectorInterfaceTests.java │ │ │ ├── SchemaMappingInspectorTestSupport.java │ │ │ ├── SchemaMappingInspectorTests.java │ │ │ └── SchemaMappingInspectorUnionTests.java │ │ │ ├── observation │ │ │ ├── DefaultDataFetcherObservationConventionTests.java │ │ │ ├── DefaultExecutionRequestObservationConventionTests.java │ │ │ └── GraphQlObservationInstrumentationTests.java │ │ │ ├── server │ │ │ ├── ConsumeOneAndNeverCompleteInterceptor.java │ │ │ ├── GraphQlRSocketHandlerTests.java │ │ │ ├── TimeoutWebGraphQlInterceptorTests.java │ │ │ ├── WebGraphQlHandlerTests.java │ │ │ ├── WebGraphQlInterceptorTests.java │ │ │ ├── WebSocketHandlerTestSupport.java │ │ │ ├── support │ │ │ │ └── BearerTokenAuthenticationExtractorTests.java │ │ │ ├── webflux │ │ │ │ ├── AuthenticationWebSocketInterceptorTests.java │ │ │ │ ├── GraphQlHttpHandlerTests.java │ │ │ │ ├── GraphQlHttpProtocolTests.java │ │ │ │ ├── GraphQlRequestPredicatesTests.java │ │ │ │ ├── GraphQlSseHandlerTests.java │ │ │ │ ├── GraphQlWebSocketHandlerTests.java │ │ │ │ ├── GraphiQlHandlerTests.java │ │ │ │ └── TestWebSocketSession.java │ │ │ └── webmvc │ │ │ │ ├── AuthenticationWebSocketInterceptorTests.java │ │ │ │ ├── GraphQlHttpHandlerTests.java │ │ │ │ ├── GraphQlHttpProtocolTests.java │ │ │ │ ├── GraphQlRequestPredicatesTests.java │ │ │ │ ├── GraphQlSseHandlerTests.java │ │ │ │ ├── GraphQlWebSocketHandlerTests.java │ │ │ │ ├── GraphiQlHandlerTests.java │ │ │ │ └── TestWebSocketSession.java │ │ │ └── support │ │ │ ├── CachingDocumentSourceTests.java │ │ │ ├── DefaultGraphQlRequestTests.java │ │ │ └── ResourceDocumentSourceTests.java │ ├── kotlin │ │ └── org │ │ │ └── springframework │ │ │ └── graphql │ │ │ └── data │ │ │ └── method │ │ │ └── annotation │ │ │ └── support │ │ │ ├── BatchMappingInvocationKotlinTests.kt │ │ │ └── SchemaMappingInvocationKotlinTests.kt │ └── resources │ │ ├── books │ │ ├── book-document.graphql │ │ ├── federation-schema.graphqls │ │ ├── pagination-schema.graphqls │ │ └── schema.graphqls │ │ ├── graphql-documents │ │ └── greeting.graphql │ │ └── log4j2-test.xml │ └── testFixtures │ └── java │ └── org │ └── springframework │ └── graphql │ ├── GraphQlServiceSetup.java │ ├── GraphQlSetup.java │ ├── MockWebServerExtension.java │ ├── TestExecutionGraphQlService.java │ ├── TestExecutionRequest.java │ ├── client │ ├── TestWebSocketClient.java │ └── TestWebSocketConnection.java │ ├── execution │ └── MockExecutionGraphQlService.java │ └── server │ └── WebGraphQlSetup.java └── src └── checkstyle ├── checkstyle-suppressions.xml ├── checkstyle.xml └── import-control.xml /.github/actions/await-http-resource/action.yml: -------------------------------------------------------------------------------- 1 | name: Await HTTP Resource 2 | description: 'Waits for an HTTP resource to be available (a HEAD request succeeds)' 3 | inputs: 4 | url: 5 | description: 'URL of the resource to await' 6 | required: true 7 | runs: 8 | using: composite 9 | steps: 10 | - name: Await HTTP resource 11 | shell: bash 12 | run: | 13 | url=${{ inputs.url }} 14 | echo "Waiting for $url" 15 | until curl --fail --head --silent ${{ inputs.url }} > /dev/null 16 | do 17 | echo "." 18 | sleep 60 19 | done 20 | echo "$url is available" 21 | -------------------------------------------------------------------------------- /.github/actions/create-github-release/action.yml: -------------------------------------------------------------------------------- 1 | name: Create GitHub Release 2 | description: Create the release on GitHub with a changelog 3 | inputs: 4 | milestone: 5 | description: Name of the GitHub milestone for which a release will be created 6 | required: true 7 | token: 8 | description: Token to use for authentication with GitHub 9 | required: true 10 | pre-release: 11 | description: Whether the release is a pre-release (a milestone or release candidate) 12 | required: false 13 | default: 'false' 14 | runs: 15 | using: composite 16 | steps: 17 | - name: Generate Changelog 18 | uses: spring-io/github-changelog-generator@86958813a62af8fb223b3fd3b5152035504bcb83 #v0.0.12 19 | with: 20 | milestone: ${{ inputs.milestone }} 21 | token: ${{ inputs.token }} 22 | config-file: .github/actions/create-github-release/changelog-generator.yml 23 | - name: Create GitHub Release 24 | env: 25 | GITHUB_TOKEN: ${{ inputs.token }} 26 | shell: bash 27 | run: gh release create ${{ format('v{0}', inputs.milestone) }} --notes-file changelog.md ${{ inputs.pre-release == 'true' && '--prerelease' || '' }} 28 | -------------------------------------------------------------------------------- /.github/actions/create-github-release/changelog-generator.yml: -------------------------------------------------------------------------------- 1 | changelog: 2 | repository: spring-projects/spring-graphql 3 | sections: 4 | - title: ":star: New Features" 5 | labels: 6 | - "type: enhancement" 7 | - title: ":lady_beetle: Bug Fixes" 8 | labels: 9 | - "type: bug" 10 | - "type: regression" 11 | - title: ":notebook_with_decorative_cover: Documentation" 12 | labels: 13 | - "type: documentation" 14 | - title: ":hammer: Dependency Upgrades" 15 | sort: "title" 16 | labels: 17 | - "type: dependency-upgrade" 18 | contributors: 19 | exclude: 20 | names: 21 | - "bclozel" 22 | - "rstoyanchev" -------------------------------------------------------------------------------- /.github/actions/send-notification/action.yml: -------------------------------------------------------------------------------- 1 | name: Send Notification 2 | description: 'Sends a Google Chat message as a notification of the job''s outcome' 3 | inputs: 4 | build-scan-url: 5 | description: 'URL of the build scan to include in the notification' 6 | required: false 7 | run-name: 8 | description: 'Name of the run to include in the notification' 9 | required: false 10 | default: ${{ format('{0} {1}', github.ref_name, github.job) }} 11 | status: 12 | description: 'Status of the job' 13 | required: true 14 | webhook-url: 15 | description: 'Google Chat Webhook URL' 16 | required: true 17 | runs: 18 | using: composite 19 | steps: 20 | - name: Prepare Variables 21 | shell: bash 22 | run: | 23 | echo "BUILD_SCAN=${{ inputs.build-scan-url == '' && ' [build scan unavailable]' || format(' [<{0}|Build Scan>]', inputs.build-scan-url) }}" >> "$GITHUB_ENV" 24 | echo "RUN_URL=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> "$GITHUB_ENV" 25 | - name: Success Notification 26 | if: ${{ inputs.status == 'success' }} 27 | shell: bash 28 | run: | 29 | curl -X POST '${{ inputs.webhook-url }}' -H 'Content-Type: application/json' -d '{ text: "<${{ env.RUN_URL }}|${{ inputs.run-name }}> was successful ${{ env.BUILD_SCAN }}"}' || true 30 | - name: Failure Notification 31 | if: ${{ inputs.status == 'failure' }} 32 | shell: bash 33 | run: | 34 | curl -X POST '${{ inputs.webhook-url }}' -H 'Content-Type: application/json' -d '{ text: " *<${{ env.RUN_URL }}|${{ inputs.run-name }}> failed* ${{ env.BUILD_SCAN }}"}' || true 35 | - name: Cancel Notification 36 | if: ${{ inputs.status == 'cancelled' }} 37 | shell: bash 38 | run: | 39 | curl -X POST '${{ inputs.webhook-url }}' -H 'Content-Type: application/json' -d '{ text: "<${{ env.RUN_URL }}|${{ inputs.run-name }}> was cancelled"}' || true -------------------------------------------------------------------------------- /.github/actions/sync-to-maven-central/artifacts.spec: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | { 4 | "aql": { 5 | "items.find": { 6 | "$and": [ 7 | { 8 | "@build.name": "${buildName}", 9 | "@build.number": "${buildNumber}", 10 | "path": { 11 | "$nmatch": "org/springframework/graphql/spring-graphql-docs/*" 12 | } 13 | } 14 | ] 15 | } 16 | }, 17 | "target": "nexus/" 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /.github/dco.yml: -------------------------------------------------------------------------------- 1 | require: 2 | members: false 3 | 4 | -------------------------------------------------------------------------------- /.github/workflows/backport-bot.yml: -------------------------------------------------------------------------------- 1 | name: Backport Bot 2 | 3 | on: 4 | issues: 5 | types: [labeled] 6 | pull_request: 7 | types: [labeled] 8 | push: 9 | branches: 10 | - '*.x' 11 | permissions: 12 | contents: read 13 | jobs: 14 | build: 15 | permissions: 16 | contents: read 17 | issues: write 18 | pull-requests: write 19 | runs-on: ubuntu-latest 20 | steps: 21 | - name: Check out code 22 | uses: actions/checkout@v4 23 | - name: Set up Java 24 | uses: actions/setup-java@v4 25 | with: 26 | distribution: 'liberica' 27 | java-version: 17 28 | - name: Download BackportBot 29 | run: wget https://github.com/spring-io/backport-bot/releases/download/latest/backport-bot-0.0.1-SNAPSHOT.jar 30 | - name: Backport 31 | env: 32 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 33 | GITHUB_EVENT: ${{ toJSON(github.event) }} 34 | run: java -jar backport-bot-0.0.1-SNAPSHOT.jar --github.accessToken="$GITHUB_TOKEN" --github.event_name "$GITHUB_EVENT_NAME" --github.event "$GITHUB_EVENT" -------------------------------------------------------------------------------- /.github/workflows/build-and-deploy-snapshot.yml: -------------------------------------------------------------------------------- 1 | name: Build and Deploy Snapshot 2 | on: 3 | push: 4 | branches: 5 | - main 6 | permissions: 7 | actions: write 8 | concurrency: 9 | group: ${{ github.workflow }}-${{ github.ref }} 10 | jobs: 11 | build-and-deploy-snapshot: 12 | name: Build and Deploy Snapshot 13 | runs-on: ubuntu-latest 14 | if: ${{ github.repository == 'spring-projects/spring-graphql' }} 15 | steps: 16 | - name: Check Out Code 17 | uses: actions/checkout@v4 18 | - name: Build and Publish 19 | id: build-and-publish 20 | uses: ./.github/actions/build-and-publish 21 | with: 22 | develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }} 23 | publish: true 24 | - name: Deploy 25 | uses: spring-io/artifactory-deploy-action@dc1913008c0599f0c4b1fdafb6ff3c502b3565ea # v0.0.2 26 | with: 27 | uri: 'https://repo.spring.io' 28 | username: ${{ secrets.ARTIFACTORY_USERNAME }} 29 | password: ${{ secrets.ARTIFACTORY_PASSWORD }} 30 | build-name: ${{ format('spring-graphql-{0}', github.ref_name)}} 31 | repository: 'libs-snapshot-local' 32 | folder: 'deployment-repository' 33 | signing-key: ${{ secrets.GPG_PRIVATE_KEY }} 34 | signing-passphrase: ${{ secrets.GPG_PASSPHRASE }} 35 | artifact-properties: | 36 | /**/spring-graphql-docs-*.zip::zip.name=spring-graphql,zip.type=docs,zip.deployed=false 37 | - name: Send Notification 38 | uses: ./.github/actions/send-notification 39 | if: always() 40 | with: 41 | webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }} 42 | status: ${{ job.status }} 43 | build-scan-url: ${{ steps.build-and-publish.outputs.build-scan-url }} 44 | run-name: ${{ format('{0} | Linux | Java 17', github.ref_name) }} 45 | outputs: 46 | version: ${{ steps.build-and-publish.outputs.version }} -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | push: 4 | branches: 5 | - main 6 | concurrency: 7 | group: ${{ github.workflow }}-${{ github.ref }} 8 | jobs: 9 | ci: 10 | name: '${{ matrix.os.name}} | Java ${{ matrix.java.version}}' 11 | runs-on: ${{ matrix.os.id }} 12 | if: ${{ github.repository == 'spring-projects/spring-graphql' }} 13 | strategy: 14 | matrix: 15 | os: 16 | - id: ubuntu-latest 17 | name: Linux 18 | java: 19 | - version: 21 20 | toolchain: true 21 | - version: 22 22 | toolchain: true 23 | steps: 24 | - name: Check Out Code 25 | uses: actions/checkout@v4 26 | - name: Build 27 | id: build 28 | uses: ./.github/actions/build-and-publish 29 | with: 30 | java-version: ${{ matrix.java.version }} 31 | java-distribution: ${{ matrix.java.distribution || 'liberica' }} 32 | java-toolchain: ${{ matrix.java.toolchain }} 33 | develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }} 34 | - name: Send Notification 35 | uses: ./.github/actions/send-notification 36 | if: always() 37 | with: 38 | webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }} 39 | status: ${{ job.status }} 40 | build-scan-url: ${{ steps.build.outputs.build-scan-url }} 41 | run-name: ${{ format('{0} | {1} | Java {2}', github.ref_name, matrix.os.name, matrix.java.version) }} -------------------------------------------------------------------------------- /.github/workflows/delete-staged-release.yml: -------------------------------------------------------------------------------- 1 | name: Delete Staged Release 2 | on: 3 | workflow_dispatch: 4 | inputs: 5 | build-version: 6 | description: 'Version of the build to delete' 7 | required: true 8 | jobs: 9 | delete-staged-release: 10 | name: Delete Staged Release 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Set up JFrog CLI 14 | uses: jfrog/setup-jfrog-cli@ff5cb544114ffc152db9cea1cd3d5978d5074946 # v4.5.11 15 | env: 16 | JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }} 17 | - name: Delete Build 18 | run: jfrog rt delete --build spring-graphql-${{ github.event.inputs.build-version }} -------------------------------------------------------------------------------- /.github/workflows/deploy-docs.yml: -------------------------------------------------------------------------------- 1 | name: Deploy Docs 2 | on: 3 | push: 4 | branches-ignore: [ gh-pages ] 5 | tags: '**' 6 | repository_dispatch: 7 | types: request-build-reference # legacy 8 | #schedule: 9 | #- cron: '0 10 * * *' # Once per day at 10am UTC 10 | workflow_dispatch: 11 | permissions: 12 | actions: write 13 | jobs: 14 | build: 15 | runs-on: ubuntu-latest 16 | if: github.repository_owner == 'spring-projects' 17 | steps: 18 | - name: Checkout 19 | uses: actions/checkout@v4 20 | with: 21 | ref: docs-build 22 | fetch-depth: 1 23 | - name: Dispatch (partial build) 24 | if: github.ref_type == 'branch' 25 | env: 26 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 27 | run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD) -f build-refname=${{ github.ref_name }} 28 | - name: Dispatch (full build) 29 | if: github.ref_type == 'tag' 30 | env: 31 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 32 | run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD) 33 | -------------------------------------------------------------------------------- /.github/workflows/update-antora-ui-spring.yml: -------------------------------------------------------------------------------- 1 | name: Update Antora UI Spring 2 | 3 | on: 4 | schedule: 5 | - cron: '0 10 * * *' # Once per day at 10am UTC 6 | workflow_dispatch: 7 | 8 | permissions: 9 | pull-requests: write 10 | issues: write 11 | contents: write 12 | 13 | jobs: 14 | update-antora-ui-spring: 15 | runs-on: ubuntu-latest 16 | name: Update on Supported Branches 17 | strategy: 18 | matrix: 19 | branch: [ '1.3.x', '1.4.x', 'main' ] 20 | steps: 21 | - uses: spring-io/spring-doc-actions/update-antora-spring-ui@e28269199d1d27975cf7f65e16d6095c555b3cd0 # v0.0.20 22 | name: Update 23 | with: 24 | docs-branch: ${{ matrix.branch }} 25 | token: ${{ secrets.GITHUB_TOKEN }} 26 | antora-file-path: 'spring-graphql-docs/antora-playbook.yml' 27 | update-antora-ui-spring-docs-build: 28 | runs-on: ubuntu-latest 29 | name: Update on docs-build 30 | steps: 31 | - uses: spring-io/spring-doc-actions/update-antora-spring-ui@e28269199d1d27975cf7f65e16d6095c555b3cd0 # v0.0.20 32 | name: Update 33 | with: 34 | docs-branch: 'docs-build' 35 | token: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | buildSrc/build 3 | /spring-*/build 4 | /platform/build 5 | node_modules/ 6 | .full-build 7 | 8 | /**/src/**/generated 9 | .gradle 10 | .idea/* 11 | !.idea/icon.svg 12 | out 13 | *.iml 14 | .DS_Store 15 | 16 | # eclipse 17 | .classpath 18 | .project 19 | .settings/ 20 | bin/ 21 | -------------------------------------------------------------------------------- /.sdkmanrc: -------------------------------------------------------------------------------- 1 | # Enable auto-env through the sdkman_auto_env config 2 | # Add key=value pairs of SDKs to use below 3 | java=17.0.15-librca -------------------------------------------------------------------------------- /buildSrc/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "java-gradle-plugin" 3 | id "checkstyle" 4 | } 5 | 6 | repositories { 7 | mavenCentral() 8 | gradlePluginPortal() 9 | } 10 | 11 | ext { 12 | def propertiesFile = new File(new File("$projectDir").parentFile, "gradle.properties") 13 | propertiesFile.withInputStream { 14 | def properties = new Properties() 15 | properties.load(it) 16 | set("kotlinVersion", properties["kotlinVersion"]) 17 | } 18 | } 19 | 20 | dependencies { 21 | checkstyle("com.puppycrawl.tools:checkstyle:${checkstyle.toolVersion}") 22 | checkstyle("io.spring.javaformat:spring-javaformat-checkstyle:${javaFormatVersion}") 23 | 24 | implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}") 25 | implementation("io.spring.javaformat:spring-javaformat-gradle-plugin:${javaFormatVersion}") 26 | implementation("net.ltgt.errorprone:net.ltgt.errorprone.gradle.plugin:${errorProneVersion}") 27 | implementation "com.tngtech.archunit:archunit:1.4.0" 28 | } 29 | 30 | checkstyle { 31 | toolVersion = "10.12.4" 32 | } 33 | 34 | gradlePlugin { 35 | plugins { 36 | conventionsPlugin { 37 | id = "org.springframework.graphql.conventions" 38 | implementationClass = "org.springframework.graphql.build.ConventionsPlugin" 39 | } 40 | architecturePlugin { 41 | id = "org.springframework.graphql.architecture" 42 | implementationClass = "org.springframework.graphql.build.architecture.ArchitecturePlugin" 43 | } 44 | } 45 | } 46 | 47 | test { 48 | useJUnitPlatform() 49 | } -------------------------------------------------------------------------------- /buildSrc/gradle.properties: -------------------------------------------------------------------------------- 1 | javaFormatVersion=0.0.43 2 | errorProneVersion=4.2.0 -------------------------------------------------------------------------------- /buildSrc/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | mavenCentral() 4 | gradlePluginPortal() 5 | } 6 | resolutionStrategy { 7 | eachPlugin { 8 | if (requested.id.id == "io.spring.javaformat") { 9 | useModule "io.spring.javaformat:spring-javaformat-gradle-plugin:${requested.version}" 10 | } 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /buildSrc/src/main/java/org/springframework/graphql/build/conventions/DeploymentConventions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.build.conventions; 18 | 19 | import org.gradle.api.Project; 20 | import org.gradle.api.publish.PublishingExtension; 21 | import org.gradle.api.publish.maven.plugins.MavenPublishPlugin; 22 | 23 | /** 24 | * Convention that configures a local deployment Maven repository on the CI 25 | * so that the Concourse resource can later push it to a remote repository. 26 | * 27 | * @author Brian Clozel 28 | */ 29 | public class DeploymentConventions { 30 | 31 | public void apply(Project project) { 32 | project.getPlugins().apply(MavenPublishPlugin.class); 33 | project.getPlugins().withType(MavenPublishPlugin.class).forEach((mavenPublishPlugin) -> { 34 | PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class); 35 | if (project.hasProperty("deploymentRepository")) { 36 | publishing.getRepositories().maven((mavenArtifactRepository) -> { 37 | mavenArtifactRepository.setUrl(project.property("deploymentRepository")); 38 | mavenArtifactRepository.setName("deployment"); 39 | }); 40 | } 41 | }); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | version=2.0.0-SNAPSHOT 2 | 3 | org.gradle.caching=true 4 | org.gradle.daemon=true 5 | org.gradle.parallel=true 6 | org.gradle.jvmargs=-Dfile.encoding=UTF-8 7 | 8 | kotlinVersion=2.1.20 9 | 10 | kotlin.stdlib.default.dependency=false 11 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-projects/spring-graphql/4b98cfb1a444f10a0881854f2c20e87da254dc52/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | mavenCentral() 4 | gradlePluginPortal() 5 | } 6 | resolutionStrategy { 7 | eachPlugin { 8 | if (requested.id.id == 'org.springframework.boot') { 9 | useModule("org.springframework.boot:spring-boot-gradle-plugin:${requested.version}") 10 | } 11 | } 12 | } 13 | } 14 | 15 | plugins { 16 | id "org.gradle.toolchains.foojay-resolver-convention" version "1.0.0" 17 | id "io.spring.develocity.conventions" version "0.0.22" 18 | } 19 | 20 | rootProject.name = 'spring-graphql' 21 | include 'platform', 22 | 'spring-graphql', 23 | 'spring-graphql-test', 24 | 'spring-graphql-docs' 25 | 26 | -------------------------------------------------------------------------------- /spring-graphql-docs/.github/workflows/deploy-docs.yml: -------------------------------------------------------------------------------- 1 | name: Deploy Docs 2 | on: 3 | push: 4 | branches-ignore: [ gh-pages ] 5 | tags: '**' 6 | repository_dispatch: 7 | types: request-build-reference # legacy 8 | #schedule: 9 | #- cron: '0 10 * * *' # Once per day at 10am UTC 10 | workflow_dispatch: 11 | permissions: 12 | actions: write 13 | jobs: 14 | build: 15 | runs-on: ubuntu-latest 16 | # FIXME enable when pushed to spring-projects 17 | # if: github.repository_owner == 'spring-projects' 18 | steps: 19 | - name: Checkout 20 | uses: actions/checkout@v3 21 | with: 22 | ref: docs-build 23 | fetch-depth: 1 24 | - name: Dispatch (partial build) 25 | if: github.ref_type == 'branch' 26 | env: 27 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 28 | run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD) -f build-refname=${{ github.ref_name }} 29 | - name: Dispatch (full build) 30 | if: github.ref_type == 'tag' 31 | env: 32 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 33 | run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD) 34 | -------------------------------------------------------------------------------- /spring-graphql-docs/antora-playbook.yml: -------------------------------------------------------------------------------- 1 | antora: 2 | extensions: 3 | - require: '@springio/antora-extensions' 4 | root_component_name: 'graphql' 5 | site: 6 | title: Spring GraphQL 7 | url: https://docs.spring.io/spring-graphql/reference 8 | robots: allow 9 | git: 10 | ensure_git_suffix: false 11 | content: 12 | sources: 13 | - url: ./.. 14 | branches: HEAD 15 | start_path: spring-graphql-docs 16 | worktrees: true 17 | asciidoc: 18 | attributes: 19 | page-stackoverflow-url: https://stackoverflow.com/tags/spring-graphql 20 | page-pagination: '' 21 | hide-uri-scheme: '@' 22 | tabs-sync-option: '@' 23 | include-java: 'example$docs-src/main/java/org/springframework/graphql/docs' 24 | extensions: 25 | - '@asciidoctor/tabs' 26 | - '@springio/asciidoctor-extensions' 27 | - '@springio/asciidoctor-extensions/include-code-extension' 28 | urls: 29 | latest_version_segment_strategy: redirect:to 30 | latest_version_segment: '' 31 | redirect_facility: httpd 32 | ui: 33 | bundle: 34 | url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.4.18/ui-bundle.zip 35 | runtime: 36 | log: 37 | failure_level: warn 38 | -------------------------------------------------------------------------------- /spring-graphql-docs/antora.yml: -------------------------------------------------------------------------------- 1 | name: graphql 2 | version: true 3 | title: Spring GraphQL 4 | nav: 5 | - modules/ROOT/nav.adoc 6 | ext: 7 | collector: 8 | run: 9 | command: gradlew -q -PbuildSrc.skipTests=true "-Dorg.gradle.jvmargs=-Xmx3g -XX:+HeapDumpOnOutOfMemoryError" :spring-graphql-docs:generateAntoraYml 10 | local: true 11 | scan: 12 | dir: ./build/generated-antora-resources 13 | 14 | asciidoc: 15 | attributes: 16 | attribute-missing: 'warn' 17 | chomp: 'all' 18 | docs-site: https://docs.spring.io 19 | include-java: 'example$docs-src/main/java/org/springframework/graphql/docs' 20 | include-resources: 'example$docs-src/main/resources' 21 | github-tag: main 22 | github-repo: spring-projects/spring-graphql 23 | github-raw: https://raw.githubusercontent.com/{github-repo}/{github-tag} 24 | github-issues: https://github.com/{github-repo}/issues/ 25 | github-main-branch: https://github.com/{github-repo}/tree/main 26 | github-10x-branch: https://github.com/{github-repo}/tree/1.0.x 27 | github-wiki: https://github.com/{github-repo}/wiki 28 | graphql-java-docs: https://www.graphql-java.com/documentation 29 | javadoc: https://docs.spring.io/spring-graphql/docs/{spring-graphql-version}/api 30 | # version attributes from main build.gradle 31 | spring-framework-ref-docs: https://docs.spring.io/spring-framework/reference 32 | spring-boot-ref-docs: https://docs.spring.io/spring-boot/{spring-boot-version} 33 | examples-repo: https://github.com/spring-projects/spring-graphql-examples -------------------------------------------------------------------------------- /spring-graphql-docs/modules/ROOT/examples/docs-src: -------------------------------------------------------------------------------- 1 | ../../../src/ -------------------------------------------------------------------------------- /spring-graphql-docs/modules/ROOT/nav.adoc: -------------------------------------------------------------------------------- 1 | * xref:index.adoc[Overview] 2 | * xref:transports.adoc[] 3 | * xref:request-execution.adoc[] 4 | * xref:data.adoc[] 5 | * xref:controllers.adoc[] 6 | * xref:security.adoc[] 7 | * xref:observability.adoc[] 8 | * xref:graalvm-native.adoc[] 9 | * xref:federation.adoc[] 10 | * xref:client.adoc[] 11 | * xref:codegen.adoc[] 12 | * xref:graphiql.adoc[] 13 | * xref:testing.adoc[] 14 | * xref:boot-starter.adoc[] 15 | * xref:standalone-setup.adoc[] 16 | * xref:samples.adoc[] 17 | -------------------------------------------------------------------------------- /spring-graphql-docs/modules/ROOT/pages/boot-starter.adoc: -------------------------------------------------------------------------------- 1 | [[boot-starter]] 2 | = Boot Starter 3 | 4 | Spring Boot provides a starter for building GraphQL applications with Spring for GraphQL. 5 | For version information, see the 6 | https://github.com/spring-projects/spring-graphql/wiki/Spring-for-GraphQL-Versions[Spring for GraphQL Versions] wiki page. 7 | 8 | The easiest way to get started is via https://start.spring.io by selecting 9 | "Spring for GraphQL" along with an underlying transport such as Spring MVC of WebFlux over 10 | HTTP or WebSocket, or over RSocket. Refer to the 11 | {spring-boot-ref-docs}/reference/web/spring-graphql.html[Spring for GraphQL Starter] 12 | section in the Spring Boot reference for details on supported transports, auto-configuration related 13 | features, and more. For testing support, see 14 | {spring-boot-ref-docs}/reference/testing/spring-boot-applications.html#testing.spring-boot-applications.spring-graphql-tests[Auto-Configured GraphQL Tests]. 15 | 16 | For further reference, check the following GraphQL related: 17 | 18 | - {spring-boot-ref-docs}/appendix/application-properties/index.html#appendix.application-properties.web[Configuration Properties] 19 | - {spring-boot-ref-docs}/appendix/auto-configuration-classes/core.html[GraphQL Auto-Configuration Classes] 20 | - {spring-boot-ref-docs}/appendix/auto-configuration-classes/actuator.html[GraphQL Actuator Auto-Configuration Classes] 21 | 22 | -------------------------------------------------------------------------------- /spring-graphql-docs/modules/ROOT/pages/codegen.adoc: -------------------------------------------------------------------------------- 1 | [[codegen]] 2 | = Code Generation 3 | 4 | You can use tools such as 5 | https://netflix.github.io/dgs/generating-code-from-schema/[DGS Codegen] to generate 6 | Java types from the GraphQL schema. The following can be generated: 7 | 8 | 1. Client types for requests (e.g. query, mutation) input types, and response selection types. 9 | 2. Data types corresponding to GraphQL schema types. 10 | 11 | Code generation may not be ideal for your own application's data types especially if you 12 | want to add logic to them. Code generation, however, is a good fit for client types since 13 | those define the request, and don't need to have other logic. As a client, you may also 14 | choose to generate the data types for the response. 15 | 16 | Start by following the instructions for the DGS code generation plugin to generate client API types. 17 | Then you can xref:client.adoc#client.dgsgraphqlclient[use client generated types with Spring's DgsGraphQlClient]. 18 | 19 | TIP: Spring Initializer at https://start.spring.io can create a Spring project with 20 | the DGS Codegen Gradle or Maven plugin. -------------------------------------------------------------------------------- /spring-graphql-docs/modules/ROOT/pages/index.adoc: -------------------------------------------------------------------------------- 1 | [[overview]] 2 | = Spring for GraphQL 3 | 4 | Spring for GraphQL provides support for Spring applications built on 5 | https://www.graphql-java.com/[GraphQL Java]. It is a joint collaboration between the 6 | GraphQL Java team and Spring engineering. 7 | 8 | Spring for GraphQL is the successor of the 9 | https://github.com/graphql-java/graphql-java-spring[GraphQL Java Spring] project from 10 | the GraphQL Java team. It aims to be the foundation for all Spring, GraphQL applications. 11 | 12 | Please, use our https://github.com/spring-projects/spring-graphql/issues[issue tracker] 13 | to report a problem, discuss a design issue, or to request a feature. 14 | 15 | Check the https://github.com/spring-projects/spring-graphql/wiki[Wiki]. 16 | for what's new, baseline requirements, and upgrade notes, and other cross-version information. 17 | 18 | To get started, see the xref:boot-starter.adoc[Boot Starter] and xref:samples.adoc[Samples] sections. -------------------------------------------------------------------------------- /spring-graphql-docs/modules/ROOT/pages/samples.adoc: -------------------------------------------------------------------------------- 1 | [[samples]] 2 | = Samples 3 | 4 | Please, see the {examples-repo}[spring-graphql-examples] repository. 5 | -------------------------------------------------------------------------------- /spring-graphql-docs/modules/ROOT/pages/security.adoc: -------------------------------------------------------------------------------- 1 | [[security]] 2 | = Security 3 | 4 | The path to a xref:transports.adoc#server.transports.http[Web] GraphQL endpoint can be secured with HTTP 5 | URL security to ensure that only authenticated users can access it. This does not, 6 | however, differentiate among different GraphQL requests on such a shared endpoint on 7 | a single URL. 8 | 9 | To apply more fine-grained security, add Spring Security annotations such as 10 | `@PreAuthorize` or `@Secured` to service methods involved in fetching specific parts of 11 | the GraphQL response. This should work due to xref:request-execution.adoc#execution.context[Context Propagation] that aims to make 12 | Security, and other context, available at the data fetching level. 13 | 14 | The 1.0.x branch of this repository contains samples for 15 | {github-10x-branch}/samples/webmvc-http-security[Spring MVC] and for 16 | {github-10x-branch}/samples/webflux-security[WebFlux]. 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /spring-graphql-docs/modules/ROOT/pages/standalone-setup.adoc: -------------------------------------------------------------------------------- 1 | [[standalone-setup]] 2 | = Standalone Setup 3 | 4 | If your application is not using Spring Boot, you are responsible for setting up the relevant Spring for GraphQL components. 5 | Assuming that your application is already configured for Spring MVC controllers, the minimum setup will require several beans. 6 | 7 | include-code::GraphQlConfiguration[] 8 | <1> The `AnnotatedControllerConfigurer` bean is responsible for detecting GraphQL `@Controller` handlers. 9 | <2> The `ExecutionGraphQlService` processes GraphQL requests in a transport-agnostic fashion. 10 | <3> The `GraphQlSource` builder is the main configuration point. Explore its API for more options. 11 | <4> The `RouterFunction` exposes the GraphQL routes as {spring-framework-ref-docs}/web/webmvc-functional.html[functional endpoints]. 12 | <5> You can then expose various transports (WebSocket, SSE, HTTP) over different routes. 13 | 14 | Spring for GraphQL offers many other options and integrations with Spring projects. 15 | For more on this, you can xref:boot-starter.adoc[explore the Spring Boot auto-configurations]. 16 | -------------------------------------------------------------------------------- /spring-graphql-docs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "antora": "3.2.0-alpha.4", 4 | "@antora/atlas-extension": "1.0.0-alpha.2", 5 | "@antora/collector-extension": "1.0.0-alpha.3", 6 | "@asciidoctor/tabs": "1.0.0-beta.6", 7 | "@springio/antora-extensions": "1.11.1", 8 | "@springio/asciidoctor-extensions": "1.0.0-alpha.10", 9 | "@opendevise/antora-release-line-extension": "1.0.0" 10 | } 11 | } -------------------------------------------------------------------------------- /spring-graphql-docs/src/docs/asciidoc/css/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2021 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | @import 'css/spring.css'; 18 | 19 | .listingblock .switch { 20 | border-style: none; 21 | display: inline-block; 22 | position: relative; 23 | bottom: -3px; 24 | } 25 | 26 | .listingblock .switch--item { 27 | padding: 10px; 28 | background-color: #e6e1dc; 29 | color: #282c34; 30 | display: inline-block; 31 | cursor: pointer; 32 | border-top-left-radius: 4px; 33 | border-top-right-radius: 4px; 34 | } 35 | 36 | .listingblock .switch--item:not(:first-child) { 37 | border-style: none; 38 | } 39 | 40 | .listingblock .switch--item.selected { 41 | background-color: #282c34; 42 | color: #e6e1dc; 43 | } 44 | 45 | .listingblock pre.highlightjs { 46 | padding: 0; 47 | } -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/client/httpgraphqlclient/ClientUsage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.client.httpgraphqlclient; 18 | 19 | import org.springframework.graphql.client.HttpGraphQlClient; 20 | import org.springframework.web.reactive.function.client.WebClient; 21 | 22 | public class ClientUsage { 23 | 24 | void create() { 25 | // tag::create[] 26 | WebClient webClient = WebClient.create("https://spring.io/graphql"); 27 | HttpGraphQlClient graphQlClient = HttpGraphQlClient.create(webClient); 28 | // end::create[] 29 | } 30 | 31 | void mutateClient() { 32 | // tag::mutate[] 33 | WebClient webClient = WebClient.create("https://spring.io/graphql"); 34 | 35 | HttpGraphQlClient graphQlClient = HttpGraphQlClient.builder(webClient) 36 | .headers((headers) -> headers.setBasicAuth("joe", "...")) 37 | .build(); 38 | 39 | // Perform requests with graphQlClient... 40 | 41 | HttpGraphQlClient anotherGraphQlClient = graphQlClient.mutate() 42 | .headers((headers) -> headers.setBasicAuth("peter", "...")) 43 | .build(); 44 | 45 | // Perform requests with anotherGraphQlClient... 46 | // end::mutate[] 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/client/httpsyncgraphqlclient/SyncClientUsage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.client.httpsyncgraphqlclient; 18 | 19 | import org.springframework.graphql.client.HttpSyncGraphQlClient; 20 | import org.springframework.web.client.RestClient; 21 | 22 | public class SyncClientUsage { 23 | 24 | void createClient() { 25 | // tag::create[] 26 | RestClient restClient = RestClient.create("https://spring.io/graphql"); 27 | HttpSyncGraphQlClient graphQlClient = HttpSyncGraphQlClient.create(restClient); 28 | // end::create[] 29 | } 30 | 31 | void mutateClient() { 32 | // tag::mutate[] 33 | RestClient restClient = RestClient.create("https://spring.io/graphql"); 34 | HttpSyncGraphQlClient graphQlClient = HttpSyncGraphQlClient.builder(restClient) 35 | .headers((headers) -> headers.setBasicAuth("joe", "...")) 36 | .build(); 37 | 38 | // Perform requests with graphQlClient... 39 | 40 | HttpSyncGraphQlClient anotherGraphQlClient = graphQlClient.mutate() 41 | .headers((headers) -> headers.setBasicAuth("peter", "...")) 42 | .build(); 43 | 44 | // Perform requests with anotherGraphQlClient... 45 | 46 | // end::mutate[] 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/client/interception/MyInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.client.interception; 18 | 19 | import reactor.core.publisher.Flux; 20 | import reactor.core.publisher.Mono; 21 | 22 | import org.springframework.graphql.client.ClientGraphQlRequest; 23 | import org.springframework.graphql.client.ClientGraphQlResponse; 24 | import org.springframework.graphql.client.GraphQlClientInterceptor; 25 | 26 | public class MyInterceptor implements GraphQlClientInterceptor { 27 | 28 | @Override 29 | public Mono intercept(ClientGraphQlRequest request, Chain chain) { 30 | // ... 31 | return chain.next(request); 32 | } 33 | 34 | @Override 35 | public Flux interceptSubscription(ClientGraphQlRequest request, SubscriptionChain chain) { 36 | // ... 37 | return chain.next(request); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/client/interception/SyncInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.client.interception; 18 | 19 | import org.springframework.graphql.client.ClientGraphQlRequest; 20 | import org.springframework.graphql.client.ClientGraphQlResponse; 21 | import org.springframework.graphql.client.SyncGraphQlClientInterceptor; 22 | 23 | public class SyncInterceptor implements SyncGraphQlClientInterceptor { 24 | 25 | @Override 26 | public ClientGraphQlResponse intercept(ClientGraphQlRequest request, Chain chain) { 27 | // ... 28 | return chain.next(request); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/client/interception/UseInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.client.interception; 18 | 19 | import java.net.URI; 20 | 21 | import org.springframework.graphql.client.WebSocketGraphQlClient; 22 | import org.springframework.web.reactive.socket.client.ReactorNettyWebSocketClient; 23 | import org.springframework.web.reactive.socket.client.WebSocketClient; 24 | 25 | public class UseInterceptor { 26 | 27 | void registerInterceptor() { 28 | // tag::register[] 29 | URI url = URI.create("wss://localhost:8080/graphql"); 30 | WebSocketClient client = new ReactorNettyWebSocketClient(); 31 | 32 | WebSocketGraphQlClient graphQlClient = WebSocketGraphQlClient.builder(url, client) 33 | .interceptor(new MyInterceptor()) 34 | .build(); 35 | // end::register[] 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/client/requests/documentsource/DocumentSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.client.requests.documentsource; 18 | 19 | import org.springframework.graphql.client.GraphQlClient; 20 | 21 | public class DocumentSource { 22 | 23 | void documentSource() { 24 | GraphQlClient graphQlClient = null; 25 | // tag::documentSource[] 26 | Project project = graphQlClient.documentName("projectReleases") // <1> 27 | .variable("slug", "spring-framework") // <2> 28 | .retrieveSync("projectReleases.project") 29 | .toEntity(Project.class); 30 | // end::documentSource[] 31 | } 32 | 33 | record Project() { 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/client/rsocketgraphqlclient/RSocketClientUsage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.client.rsocketgraphqlclient; 18 | 19 | import java.net.URI; 20 | 21 | import io.rsocket.transport.netty.client.WebsocketClientTransport; 22 | 23 | import org.springframework.graphql.client.RSocketGraphQlClient; 24 | 25 | public class RSocketClientUsage { 26 | 27 | void create() { 28 | // tag::create[] 29 | URI uri = URI.create("wss://localhost:8080/rsocket"); 30 | WebsocketClientTransport transport = WebsocketClientTransport.create(uri); 31 | 32 | RSocketGraphQlClient client = RSocketGraphQlClient.builder() 33 | .clientTransport(transport) 34 | .build(); 35 | // end::create[] 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/client/subscriptions/execute/ExecuteSubscription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.client.subscriptions.execute; 18 | 19 | import reactor.core.publisher.Flux; 20 | 21 | import org.springframework.graphql.client.ClientResponseField; 22 | import org.springframework.graphql.client.GraphQlClient; 23 | 24 | public class ExecuteSubscription { 25 | 26 | void subscriptionExecute() { 27 | GraphQlClient client = null; 28 | // tag::subscriptionExecute[] 29 | Flux greetingFlux = client.document("subscription { greetings }") 30 | .executeSubscription() 31 | .map((response) -> { 32 | if (!response.isValid()) { 33 | // Request failure... 34 | } 35 | 36 | ClientResponseField field = response.field("project"); 37 | if (field.getValue() == null) { 38 | if (field.getErrors().isEmpty()) { 39 | // Optional field set to null... 40 | } 41 | else { 42 | // Field failure... 43 | } 44 | } 45 | 46 | return field.toEntity(String.class); 47 | }); 48 | // end::subscriptionExecute[] 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/client/subscriptions/retrieve/RetrieveSubscription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.client.subscriptions.retrieve; 18 | 19 | import reactor.core.publisher.Flux; 20 | 21 | import org.springframework.graphql.client.GraphQlClient; 22 | 23 | public class RetrieveSubscription { 24 | 25 | void subscriptionRetrieve() { 26 | GraphQlClient client = null; 27 | // tag::subscriptionRetrieve[] 28 | Flux greetingFlux = client.document("subscription { greetings }") 29 | .retrieveSubscription("greeting") 30 | .toEntity(String.class); 31 | // end::subscriptionRetrieve[] 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/controllers/exceptionhandler/Book.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.controllers.exceptionhandler; 18 | 19 | public record Book() { 20 | } 21 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/controllers/exceptionhandler/BookController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.controllers.exceptionhandler; 18 | 19 | 20 | import graphql.GraphQLError; 21 | import graphql.GraphqlErrorBuilder; 22 | 23 | import org.springframework.graphql.data.method.annotation.Argument; 24 | import org.springframework.graphql.data.method.annotation.GraphQlExceptionHandler; 25 | import org.springframework.graphql.data.method.annotation.QueryMapping; 26 | import org.springframework.graphql.execution.ErrorType; 27 | import org.springframework.stereotype.Controller; 28 | import org.springframework.validation.BindException; 29 | 30 | @Controller 31 | public class BookController { 32 | 33 | @QueryMapping 34 | public Book bookById(@Argument Long id) { 35 | return /**/ new Book(); 36 | } 37 | 38 | @GraphQlExceptionHandler 39 | public GraphQLError handle(GraphqlErrorBuilder errorBuilder, BindException ex) { 40 | return errorBuilder 41 | .errorType(ErrorType.BAD_REQUEST) 42 | .message(ex.getMessage()) 43 | .build(); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/controllers/exceptionhandler/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.controllers.exceptionhandler; 18 | 19 | import graphql.GraphQLError; 20 | import graphql.GraphqlErrorBuilder; 21 | 22 | import org.springframework.graphql.data.method.annotation.GraphQlExceptionHandler; 23 | import org.springframework.graphql.execution.ErrorType; 24 | import org.springframework.validation.BindException; 25 | import org.springframework.web.bind.annotation.ControllerAdvice; 26 | 27 | @ControllerAdvice 28 | public class GlobalExceptionHandler { 29 | 30 | @GraphQlExceptionHandler 31 | public GraphQLError handle(GraphqlErrorBuilder errorBuilder, BindException ex) { 32 | return errorBuilder 33 | .errorType(ErrorType.BAD_REQUEST) 34 | .message(ex.getMessage()) 35 | .build(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/controllers/namespacing/Album.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.controllers.namespacing; 18 | 19 | public record Album(String id, String title) { 20 | } 21 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/controllers/namespacing/Artist.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.controllers.namespacing; 18 | 19 | public record Artist(String id, String name) { 20 | } 21 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/controllers/namespacing/MusicController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.controllers.namespacing; 18 | 19 | import java.util.List; 20 | 21 | import org.springframework.graphql.data.method.annotation.Argument; 22 | import org.springframework.graphql.data.method.annotation.QueryMapping; 23 | import org.springframework.graphql.data.method.annotation.SchemaMapping; 24 | import org.springframework.stereotype.Controller; 25 | 26 | @Controller 27 | @SchemaMapping(typeName = "MusicQueries") // <1> 28 | public class MusicController { 29 | 30 | @QueryMapping // <2> 31 | public MusicQueries music() { 32 | return new MusicQueries(); 33 | } 34 | 35 | // <3> 36 | public record MusicQueries() { 37 | 38 | } 39 | 40 | @SchemaMapping // <4> 41 | public Album album(@Argument String id) { 42 | return new Album(id, "Spring GraphQL"); 43 | } 44 | 45 | @SchemaMapping 46 | public List searchForArtist(@Argument String name) { 47 | return List.of(new Artist("100", "the Spring team")); 48 | } 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/controllers/namespacing/NamespaceConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.controllers.namespacing; 18 | 19 | import java.util.Collections; 20 | import java.util.List; 21 | 22 | import org.springframework.boot.autoconfigure.graphql.GraphQlSourceBuilderCustomizer; 23 | import org.springframework.context.annotation.Bean; 24 | import org.springframework.context.annotation.Configuration; 25 | 26 | 27 | @Configuration 28 | public class NamespaceConfiguration { 29 | 30 | @Bean 31 | public GraphQlSourceBuilderCustomizer customizer() { 32 | List queryWrappers = List.of("music", "users"); // <1> 33 | 34 | return (sourceBuilder) -> sourceBuilder.configureRuntimeWiring((wiringBuilder) -> 35 | queryWrappers.forEach((field) -> wiringBuilder.type("Query", 36 | (builder) -> builder.dataFetcher(field, (env) -> Collections.emptyMap()))) // <2> 37 | ); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/execution/graphqlsource/CustomExecutionIdProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.execution.graphqlsource; 18 | 19 | import graphql.execution.ExecutionId; 20 | import graphql.execution.ExecutionIdProvider; 21 | 22 | class CustomExecutionIdProvider implements ExecutionIdProvider { 23 | @Override 24 | public ExecutionId provide(String query, String operationName, Object context) { 25 | return null; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/execution/graphqlsource/GraphQlConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.execution.graphqlsource; 18 | 19 | import org.springframework.boot.autoconfigure.graphql.GraphQlSourceBuilderCustomizer; 20 | import org.springframework.context.annotation.Bean; 21 | import org.springframework.context.annotation.Configuration; 22 | 23 | @Configuration(proxyBeanMethods = false) 24 | public class GraphQlConfig { 25 | 26 | @Bean 27 | public GraphQlSourceBuilderCustomizer sourceBuilderCustomizer() { 28 | return (builder) -> 29 | builder.configureGraphQl((graphQlBuilder) -> 30 | graphQlBuilder.executionIdProvider(new CustomExecutionIdProvider())); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/execution/timeout/HttpTimeoutConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.execution.timeout; 18 | 19 | import java.time.Duration; 20 | 21 | import org.springframework.context.annotation.Bean; 22 | import org.springframework.context.annotation.Configuration; 23 | import org.springframework.graphql.server.TimeoutWebGraphQlInterceptor; 24 | 25 | @Configuration(proxyBeanMethods = false) 26 | public class HttpTimeoutConfiguration { 27 | 28 | @Bean 29 | public TimeoutWebGraphQlInterceptor timeoutWebGraphQlInterceptor() { 30 | return new TimeoutWebGraphQlInterceptor(Duration.ofSeconds(5)); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/execution/timeout/WebGraphQlHandlerTimeout.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.execution.timeout; 18 | 19 | import java.time.Duration; 20 | 21 | import org.springframework.graphql.execution.DefaultExecutionGraphQlService; 22 | import org.springframework.graphql.execution.GraphQlSource; 23 | import org.springframework.graphql.server.TimeoutWebGraphQlInterceptor; 24 | import org.springframework.graphql.server.WebGraphQlHandler; 25 | import org.springframework.graphql.server.webmvc.GraphQlHttpHandler; 26 | 27 | public class WebGraphQlHandlerTimeout { 28 | 29 | void configureWebGraphQlHandler() { 30 | GraphQlSource graphQlSource = GraphQlSource.schemaResourceBuilder().build(); 31 | DefaultExecutionGraphQlService executionGraphQlService = new DefaultExecutionGraphQlService(graphQlSource); 32 | 33 | // tag::interceptor[] 34 | TimeoutWebGraphQlInterceptor timeoutInterceptor = new TimeoutWebGraphQlInterceptor(Duration.ofSeconds(5)); 35 | WebGraphQlHandler webGraphQlHandler = WebGraphQlHandler 36 | .builder(executionGraphQlService) 37 | .interceptor(timeoutInterceptor) 38 | .build(); 39 | GraphQlHttpHandler httpHandler = new GraphQlHttpHandler(webGraphQlHandler); 40 | // end::interceptor[] 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/graalvm/client/Project.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.graalvm.client; 18 | 19 | import java.util.List; 20 | 21 | public record Project(String slug, String name, List releases) { 22 | } 23 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/graalvm/client/ProjectService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.graalvm.client; 18 | 19 | import reactor.core.publisher.Mono; 20 | 21 | import org.springframework.aot.hint.annotation.RegisterReflectionForBinding; 22 | import org.springframework.graphql.client.GraphQlClient; 23 | import org.springframework.stereotype.Component; 24 | 25 | @Component 26 | @RegisterReflectionForBinding(Project.class) // <2> 27 | public class ProjectService { 28 | 29 | private final GraphQlClient graphQlClient; 30 | 31 | public ProjectService(GraphQlClient graphQlClient) { 32 | this.graphQlClient = graphQlClient; 33 | } 34 | 35 | public Mono project(String projectSlug) { 36 | String document = """ 37 | query projectWithReleases($projectSlug: ID!) { 38 | project(slug: $projectSlug) { 39 | name 40 | releases { 41 | version 42 | } 43 | } 44 | } 45 | """; 46 | 47 | return this.graphQlClient.document(document) 48 | .variable("projectSlug", projectSlug) 49 | .retrieve("project") 50 | .toEntity(Project.class); // <1> 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/graalvm/client/Releases.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.graalvm.client; 18 | 19 | public record Releases(String version) { 20 | } 21 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/graalvm/server/Book.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.graalvm.server; 18 | 19 | public class Book { 20 | 21 | Long id; 22 | 23 | String name; 24 | 25 | Long authorId; 26 | 27 | public Book() { 28 | } 29 | 30 | public Book(Long id, String name, Long authorId) { 31 | this.id = id; 32 | this.name = name; 33 | this.authorId = authorId; 34 | } 35 | 36 | public Long getId() { 37 | return this.id; 38 | } 39 | 40 | public void setId(Long id) { 41 | this.id = id; 42 | } 43 | 44 | public String getName() { 45 | return this.name; 46 | } 47 | 48 | public void setName(String name) { 49 | this.name = name; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/graalvm/server/BookRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.graalvm.server; 18 | 19 | import org.springframework.data.querydsl.QuerydslPredicateExecutor; 20 | import org.springframework.data.repository.CrudRepository; 21 | import org.springframework.graphql.data.GraphQlRepository; 22 | 23 | @GraphQlRepository 24 | public interface BookRepository extends CrudRepository, QuerydslPredicateExecutor { 25 | } 26 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/graalvm/server/GraphQlConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.graalvm.server; 18 | 19 | import graphql.schema.DataFetcher; 20 | 21 | import org.springframework.aot.hint.annotation.RegisterReflectionForBinding; 22 | import org.springframework.context.annotation.Bean; 23 | import org.springframework.context.annotation.Configuration; 24 | import org.springframework.graphql.data.query.QuerydslDataFetcher; 25 | import org.springframework.graphql.execution.RuntimeWiringConfigurer; 26 | 27 | @Configuration 28 | @RegisterReflectionForBinding(Book.class) // <3> 29 | public class GraphQlConfiguration { 30 | 31 | @Bean 32 | RuntimeWiringConfigurer customWiringConfigurer(BookRepository bookRepository) { // <1> 33 | DataFetcher dataFetcher = QuerydslDataFetcher.builder(bookRepository).single(); 34 | return (wiringBuilder) -> wiringBuilder 35 | .type("Query", (builder) -> builder.dataFetcher("book", dataFetcher)); // <2> 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/graphiql/configuration/GraphiQlConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.graphiql.configuration; 18 | 19 | import org.springframework.context.annotation.Bean; 20 | import org.springframework.context.annotation.Configuration; 21 | import org.springframework.core.annotation.Order; 22 | import org.springframework.core.io.ClassPathResource; 23 | import org.springframework.graphql.server.webmvc.GraphiQlHandler; 24 | import org.springframework.web.servlet.function.RouterFunction; 25 | import org.springframework.web.servlet.function.RouterFunctions; 26 | import org.springframework.web.servlet.function.ServerResponse; 27 | 28 | @Configuration 29 | public class GraphiQlConfiguration { 30 | 31 | @Bean 32 | @Order(0) 33 | public RouterFunction graphiQlRouterFunction() { 34 | RouterFunctions.Builder builder = RouterFunctions.route(); 35 | ClassPathResource graphiQlPage = new ClassPathResource("graphiql/index.html"); // <1> 36 | GraphiQlHandler graphiQLHandler = new GraphiQlHandler("/graphql", "", graphiQlPage); // <2> 37 | builder = builder.GET("/graphiql", graphiQLHandler::handleRequest); // <3> 38 | return builder.build(); // <4> 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/server/interception/web/Person.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.server.interception.web; 18 | 19 | public record Person(String firstName, String lastName) { 20 | } 21 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/server/interception/web/RequestErrorInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.server.interception.web; 18 | 19 | import java.util.List; 20 | 21 | import graphql.GraphQLError; 22 | import graphql.GraphqlErrorBuilder; 23 | import reactor.core.publisher.Mono; 24 | 25 | import org.springframework.graphql.server.WebGraphQlInterceptor; 26 | import org.springframework.graphql.server.WebGraphQlRequest; 27 | import org.springframework.graphql.server.WebGraphQlResponse; 28 | 29 | class RequestErrorInterceptor implements WebGraphQlInterceptor { 30 | 31 | @Override 32 | public Mono intercept(WebGraphQlRequest request, Chain chain) { 33 | return chain.next(request).map((response) -> { 34 | if (response.isValid()) { 35 | return response; // <1> 36 | } 37 | 38 | List errors = response.getErrors().stream() // <2> 39 | .map((error) -> { 40 | GraphqlErrorBuilder builder = GraphqlErrorBuilder.newError(); 41 | // ... 42 | return builder.build(); 43 | }) 44 | .toList(); 45 | 46 | return response.transform((builder) -> builder.errors(errors).build()); // <3> 47 | }); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/server/transports/rsocket/GraphQlRSocketController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.server.transports.rsocket; 18 | 19 | import java.util.Map; 20 | 21 | import reactor.core.publisher.Flux; 22 | import reactor.core.publisher.Mono; 23 | 24 | import org.springframework.graphql.server.GraphQlRSocketHandler; 25 | import org.springframework.messaging.handler.annotation.MessageMapping; 26 | import org.springframework.stereotype.Controller; 27 | 28 | @Controller 29 | public class GraphQlRSocketController { 30 | 31 | private final GraphQlRSocketHandler handler; 32 | 33 | GraphQlRSocketController(GraphQlRSocketHandler handler) { 34 | this.handler = handler; 35 | } 36 | 37 | @MessageMapping("graphql") 38 | public Mono> handle(Map payload) { 39 | return this.handler.handle(payload); 40 | } 41 | 42 | @MessageMapping("graphql") 43 | public Flux> handleSubscription(Map payload) { 44 | return this.handler.handleSubscription(payload); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/testing/graphqlservicetester/ServiceSetup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.testing.graphqlservicetester; 18 | 19 | import graphql.execution.ExecutionId; 20 | 21 | import org.springframework.graphql.ExecutionGraphQlService; 22 | import org.springframework.graphql.test.tester.ExecutionGraphQlServiceTester; 23 | 24 | public class ServiceSetup { 25 | 26 | void serviceSetup() { 27 | // tag::serviceSetup[] 28 | ExecutionGraphQlService service = /**/ null; 29 | ExecutionGraphQlServiceTester tester = ExecutionGraphQlServiceTester.create(service); 30 | // end::serviceSetup[] 31 | } 32 | 33 | void customServiceSetup() { 34 | // tag::customServiceSetup[] 35 | ExecutionGraphQlService service = /**/ null; 36 | ExecutionId executionId = ExecutionId.generate(); 37 | ExecutionGraphQlServiceTester tester = ExecutionGraphQlServiceTester.builder(service) 38 | .configureExecutionInput((executionInput, builder) -> builder.executionId(executionId).build()) 39 | .build(); 40 | // end::customServiceSetup[] 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/testing/requests/nestedpaths/NestedPaths.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.testing.requests.nestedpaths; 18 | 19 | import org.springframework.graphql.test.tester.GraphQlTester; 20 | 21 | public class NestedPaths { 22 | 23 | void nestedPaths() { 24 | GraphQlTester graphQlTester = null; 25 | String document = ""; 26 | // tag::nestedPaths[] 27 | graphQlTester.document(document) 28 | .execute() 29 | .path("project", (project) -> project // <1> 30 | .path("name").entity(String.class).isEqualTo("spring-framework") 31 | .path("releases[*].version").entityList(String.class).hasSizeGreaterThan(1)); 32 | // end::nestedPaths[] 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/testing/rsocketgraphqltester/RSocketSetup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.testing.rsocketgraphqltester; 18 | 19 | import java.net.URI; 20 | 21 | import io.rsocket.transport.netty.client.WebsocketClientTransport; 22 | 23 | import org.springframework.graphql.test.tester.RSocketGraphQlTester; 24 | 25 | public class RSocketSetup { 26 | 27 | void rSocketSetup() { 28 | // tag::rsocketSetup[] 29 | URI url = URI.create("wss://localhost:8080/rsocket"); 30 | WebsocketClientTransport transport = WebsocketClientTransport.create(url); 31 | 32 | RSocketGraphQlTester client = RSocketGraphQlTester.builder() 33 | .clientTransport(transport) 34 | .build(); 35 | // end::rsocketSetup[] 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/testing/subscriptions/TestSubscriptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.testing.subscriptions; 18 | 19 | import reactor.core.publisher.Flux; 20 | import reactor.test.StepVerifier; 21 | 22 | import org.springframework.graphql.test.tester.GraphQlTester; 23 | 24 | public class TestSubscriptions { 25 | 26 | void testSubscriptions() { 27 | GraphQlTester tester = null; 28 | // tag::testSubscriptions[] 29 | Flux greetingFlux = tester.document("subscription { greetings }") 30 | .executeSubscription() 31 | .toFlux("greetings", String.class); // decode at JSONPath 32 | 33 | StepVerifier.create(greetingFlux) 34 | .expectNext("Hi") 35 | .expectNext("Bonjour") 36 | .expectNext("Hola") 37 | .verifyComplete(); 38 | // end::testSubscriptions[] 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/java/org/springframework/graphql/docs/testing/webgraphqltester/WebSetup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.docs.testing.webgraphqltester; 18 | 19 | import org.springframework.graphql.server.WebGraphQlHandler; 20 | import org.springframework.graphql.test.tester.WebGraphQlTester; 21 | 22 | public class WebSetup { 23 | 24 | void webSetup() { 25 | // tag::webSetup[] 26 | WebGraphQlHandler handler = /**/ null; 27 | WebGraphQlTester tester = WebGraphQlTester.create(handler); 28 | // end::webSetup[] 29 | } 30 | 31 | void customWebSetup() { 32 | // tag::customWebSetup[] 33 | WebGraphQlHandler handler = /**/ null; 34 | WebGraphQlTester tester = WebGraphQlTester.builder(handler) 35 | .headers((headers) -> headers.setBasicAuth("joe", "...")) 36 | .build(); 37 | // end::customWebSetup[] 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /spring-graphql-docs/src/main/resources/controllers/namespaces.graphqls: -------------------------------------------------------------------------------- 1 | type Query { 2 | music: MusicQueries 3 | users: UserQueries 4 | } 5 | 6 | type MusicQueries { 7 | album(id: ID!): Album 8 | searchForArtist(name: String!): [Artist] 9 | } 10 | 11 | type Album { 12 | id: ID! 13 | title: String! 14 | } 15 | 16 | type Artist { 17 | id: ID! 18 | name: String! 19 | } 20 | 21 | type UserQueries { 22 | user(login: String): User 23 | } 24 | 25 | type User { 26 | id: ID! 27 | login: String! 28 | } 29 | -------------------------------------------------------------------------------- /spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/AbstractDelegatingGraphQlTester.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.test.tester; 18 | 19 | 20 | /** 21 | * Base class for extensions of {@link GraphQlTester} that mainly assist with 22 | * building the underlying transport, but otherwise delegate to the default 23 | * {@link GraphQlTester} implementation for actual request execution. 24 | * 25 | *

Subclasses must implement {@link GraphQlTester#mutate()} to allow mutation 26 | * of both {@code GraphQlTester} and {@code GraphQlTransport} configuration. 27 | * 28 | * @author Rossen Stoyanchev 29 | * @since 1.0.0 30 | * @see AbstractGraphQlTesterBuilder 31 | */ 32 | public abstract class AbstractDelegatingGraphQlTester implements GraphQlTester { 33 | 34 | private final GraphQlTester delegate; 35 | 36 | 37 | protected AbstractDelegatingGraphQlTester(GraphQlTester delegate) { 38 | this.delegate = delegate; 39 | } 40 | 41 | 42 | @Override 43 | public Request document(String document) { 44 | return this.delegate.document(document); 45 | } 46 | 47 | @Override 48 | public Request documentName(String documentName) { 49 | return this.delegate.documentName(documentName); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * GraphQL client testing support. 19 | */ 20 | @NullMarked 21 | package org.springframework.graphql.test.tester; 22 | 23 | import org.jspecify.annotations.NullMarked; 24 | -------------------------------------------------------------------------------- /spring-graphql-test/src/main/resources/META-INF/native-image/org.springframework.graphql/spring-graphql/resource-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "bundles": [], 3 | "resources": { 4 | "includes": [ 5 | { 6 | "pattern": "\\Qgraphql-test\/\\E.*\\Q.graphql\\E", 7 | "condition": { 8 | "typeReachable": "org.springframework.graphql.test.tester.GraphQlTester" 9 | } 10 | }, 11 | { 12 | "pattern": "\\Qgraphql-test\/\\E.*\\Q.gql\\E", 13 | "condition": { 14 | "typeReachable": "org.springframework.graphql.test.tester.GraphQlTester" 15 | } 16 | } 17 | ] 18 | } 19 | } -------------------------------------------------------------------------------- /spring-graphql-test/src/test/java/org/springframework/graphql/test/tester/GraphQlTesterTestSupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.test.tester; 18 | 19 | import org.springframework.graphql.execution.MockExecutionGraphQlService; 20 | 21 | 22 | /** 23 | * Base class for {@link GraphQlTester} tests. 24 | * 25 | * @author Rossen Stoyanchev 26 | */ 27 | public class GraphQlTesterTestSupport { 28 | 29 | private final MockExecutionGraphQlService graphQlService = new MockExecutionGraphQlService(); 30 | 31 | private final ExecutionGraphQlServiceTester.Builder graphQlTesterBuilder = 32 | ExecutionGraphQlServiceTester.builder(this.graphQlService); 33 | 34 | private final GraphQlTester graphQlTester = this.graphQlTesterBuilder.build(); 35 | 36 | 37 | public MockExecutionGraphQlService getGraphQlService() { 38 | return this.graphQlService; 39 | } 40 | 41 | protected String getActualRequestDocument() { 42 | return this.graphQlService.getGraphQlRequest().getDocument(); 43 | } 44 | 45 | protected GraphQlTester graphQlTester() { 46 | return this.graphQlTester; 47 | } 48 | 49 | public ExecutionGraphQlServiceTester.Builder graphQlTesterBuilder() { 50 | return this.graphQlTesterBuilder; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /spring-graphql-test/src/test/java/org/springframework/graphql/test/tester/MovieCharacter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2021 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.test.tester; 18 | 19 | import org.springframework.lang.Nullable; 20 | import org.springframework.util.ObjectUtils; 21 | 22 | 23 | public class MovieCharacter { 24 | 25 | @Nullable 26 | private String name; 27 | 28 | 29 | public void setName(String name) { 30 | this.name = name; 31 | } 32 | 33 | @Nullable 34 | public String getName() { 35 | return this.name; 36 | } 37 | 38 | 39 | public static MovieCharacter create(String name) { 40 | MovieCharacter character = new MovieCharacter(); 41 | character.setName(name); 42 | return character; 43 | } 44 | 45 | 46 | @Override 47 | public boolean equals(Object other) { 48 | if (this == other) { 49 | return true; 50 | } 51 | if (other == null || getClass() != other.getClass()) { 52 | return false; 53 | } 54 | return ObjectUtils.nullSafeEquals(this.name, ((MovieCharacter) other).name); 55 | } 56 | 57 | @Override 58 | public int hashCode() { 59 | return (this.name != null) ? this.name.hashCode() : super.hashCode(); 60 | } 61 | 62 | @Override 63 | public String toString() { 64 | return "MovieCharacter[name='" + this.name + "']"; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /spring-graphql-test/src/test/resources/graphql-test/friends.graphql: -------------------------------------------------------------------------------- 1 | fragment friendsField on User { 2 | friends 3 | } 4 | -------------------------------------------------------------------------------- /spring-graphql-test/src/test/resources/graphql-test/greeting.graphql: -------------------------------------------------------------------------------- 1 | { greeting } -------------------------------------------------------------------------------- /spring-graphql-test/src/test/resources/graphql-test/me.graphql: -------------------------------------------------------------------------------- 1 | {me {name, friends}} -------------------------------------------------------------------------------- /spring-graphql-test/src/test/resources/log4j2-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/ExecutionGraphQlResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql; 18 | 19 | import graphql.ExecutionInput; 20 | import graphql.ExecutionResult; 21 | 22 | 23 | /** 24 | * Implementation of {@link GraphQlResponse} that wraps the {@link ExecutionResult} 25 | * returned from {@link graphql.GraphQL} to expose it as {@link GraphQlResponse}, 26 | * also providing access to the {@link ExecutionInput} used for the request. 27 | * 28 | * @author Rossen Stoyanchev 29 | * @since 1.0.0 30 | */ 31 | public interface ExecutionGraphQlResponse extends GraphQlResponse { 32 | 33 | /** 34 | * Return the {@link ExecutionInput} that was prepared through the 35 | * {@link ExecutionGraphQlRequest} and passed to {@link graphql.GraphQL}. 36 | */ 37 | ExecutionInput getExecutionInput(); 38 | 39 | /** 40 | * Return the {@link ExecutionResult} that was returned from the invocation 41 | * to {@link graphql.GraphQL}. 42 | */ 43 | ExecutionResult getExecutionResult(); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/ExecutionGraphQlService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql; 18 | 19 | import reactor.core.publisher.Mono; 20 | 21 | /** 22 | * Strategy to execute a GraphQL request by invoking GraphQL Java. 23 | * 24 | * @author Rossen Stoyanchev 25 | * @since 1.0.0 26 | */ 27 | public interface ExecutionGraphQlService { 28 | 29 | /** 30 | * Execute the request and return the response. 31 | * @param request the request to execute 32 | * @return the resulting response 33 | */ 34 | Mono execute(ExecutionGraphQlRequest request); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/MediaTypes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql; 18 | 19 | import org.springframework.http.MediaType; 20 | 21 | /** 22 | * Constants for well-known GraphQL media types. 23 | * @author Brian Clozel 24 | * @since 1.4.0 25 | */ 26 | public abstract class MediaTypes { 27 | 28 | /** 29 | * Standard media type for GraphQL responses over the HTTP protocol. 30 | * @see 31 | * GraphQL over HTTP specification 32 | */ 33 | public static final MediaType APPLICATION_GRAPHQL_RESPONSE = 34 | MediaType.parseMediaType("application/graphql-response+json"); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/client/AbstractDelegatingGraphQlClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.client; 18 | 19 | 20 | import org.springframework.util.Assert; 21 | 22 | /** 23 | * Base class for {@link GraphQlClient} extensions that assist with building an 24 | * underlying transport, but otherwise delegate to the default 25 | * {@link GraphQlClient} implementation to execute requests. 26 | * 27 | *

Subclasses must implement {@link GraphQlClient#mutate()} to return a 28 | * builder for the specific {@code GraphQlClient} extension. 29 | * 30 | * @author Rossen Stoyanchev 31 | * @since 1.0.0 32 | * @see AbstractGraphQlClientBuilder 33 | */ 34 | public abstract class AbstractDelegatingGraphQlClient implements GraphQlClient { 35 | 36 | private final GraphQlClient graphQlClient; 37 | 38 | 39 | protected AbstractDelegatingGraphQlClient(GraphQlClient graphQlClient) { 40 | Assert.notNull(graphQlClient, "GraphQlClient is required"); 41 | this.graphQlClient = graphQlClient; 42 | } 43 | 44 | 45 | public RequestSpec document(String document) { 46 | return this.graphQlClient.document(document); 47 | } 48 | 49 | public RequestSpec documentName(String name) { 50 | return this.graphQlClient.documentName(name); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/client/ClientGraphQlRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.client; 18 | 19 | import java.util.Map; 20 | 21 | import org.springframework.graphql.GraphQlRequest; 22 | 23 | 24 | /** 25 | * {@link GraphQlRequest} for client side use. 26 | * 27 | * @author Rossen Stoyanchev 28 | * @since 1.0.0 29 | */ 30 | public interface ClientGraphQlRequest extends GraphQlRequest { 31 | 32 | /** 33 | * Return the client request attributes. 34 | *

The attributes purely for client side request processing, i.e. available 35 | * throughout the {@link GraphQlClientInterceptor} chain, but not sent. 36 | */ 37 | Map getAttributes(); 38 | 39 | } 40 | 41 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/client/DefaultClientGraphQlRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.client; 18 | 19 | 20 | import java.util.Map; 21 | import java.util.concurrent.ConcurrentHashMap; 22 | 23 | import org.jspecify.annotations.Nullable; 24 | 25 | import org.springframework.graphql.support.DefaultGraphQlRequest; 26 | 27 | /** 28 | * Default implementation of {@link ClientGraphQlRequest}. 29 | * 30 | * @author Rossen Stoyanchev 31 | */ 32 | final class DefaultClientGraphQlRequest extends DefaultGraphQlRequest implements ClientGraphQlRequest { 33 | 34 | private final Map attributes = new ConcurrentHashMap<>(); 35 | 36 | 37 | DefaultClientGraphQlRequest( 38 | String document, @Nullable String operationName, 39 | Map variables, Map extensions, 40 | Map attributes) { 41 | 42 | super(document, operationName, variables, extensions); 43 | this.attributes.putAll(attributes); 44 | } 45 | 46 | 47 | @Override 48 | public Map getAttributes() { 49 | return this.attributes; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/client/GraphQlClientException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.client; 18 | 19 | 20 | import org.jspecify.annotations.Nullable; 21 | 22 | import org.springframework.core.NestedRuntimeException; 23 | import org.springframework.graphql.GraphQlRequest; 24 | 25 | 26 | /** 27 | * Base class for exceptions from {@code GraphQlClient}. 28 | * 29 | * @author Rossen Stoyanchev 30 | * @since 1.0.0 31 | */ 32 | @SuppressWarnings("serial") 33 | public class GraphQlClientException extends NestedRuntimeException { 34 | 35 | private final GraphQlRequest request; 36 | 37 | 38 | /** 39 | * Constructor with a message, optional cause, and the request details. 40 | * @param message the exception message to use 41 | * @param cause the original cause for the client exception 42 | * @param request the request that failed 43 | */ 44 | public GraphQlClientException(String message, @Nullable Throwable cause, GraphQlRequest request) { 45 | super(message, cause); 46 | this.request = request; 47 | } 48 | 49 | 50 | /** 51 | * Return the request for which the error occurred. 52 | */ 53 | public GraphQlRequest getRequest() { 54 | return this.request; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/client/SyncGraphQlTransport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.client; 18 | 19 | import org.springframework.graphql.GraphQlRequest; 20 | import org.springframework.graphql.GraphQlResponse; 21 | 22 | 23 | /** 24 | * Contract for blocking execution of GraphQL requests over some transport. 25 | * 26 | * @author Rossen Stoyanchev 27 | * @since 1.3.0 28 | * @see GraphQlClient.SyncBuilder 29 | */ 30 | public interface SyncGraphQlTransport { 31 | 32 | /** 33 | * Execute a request with a single response such as a "query" or "mutation". 34 | * @param request the request to execute 35 | * @return the {@code GraphQlResponse} for the response. 36 | * @throws GraphQlTransportException in case of errors due to transport or 37 | * other issues related to encoding and decoding the request and response. 38 | */ 39 | GraphQlResponse execute(GraphQlRequest request); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/client/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * This package contains a {@link org.springframework.graphql.client.GraphQlClient} 19 | * along with HTTP and WebSocket extensions. 20 | */ 21 | @NullMarked 22 | package org.springframework.graphql.client; 23 | 24 | import org.jspecify.annotations.NullMarked; 25 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/data/federation/EntityMapping.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.federation; 18 | 19 | import java.lang.annotation.Documented; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | import org.springframework.core.annotation.AliasFor; 26 | 27 | /** 28 | * Annotation for mapping a handler method to a federated schema type. 29 | * 30 | * @author Rossen Stoyanchev 31 | * @since 1.3.0 32 | */ 33 | @Target({ElementType.TYPE, ElementType.METHOD}) 34 | @Retention(RetentionPolicy.RUNTIME) 35 | @Documented 36 | public @interface EntityMapping { 37 | 38 | /** 39 | * Customize the name of the entity to map to. 40 | *

By default, if not specified, this is initialized from the method name, 41 | * with the first letter changed to upper case via {@link Character#toUpperCase}. 42 | */ 43 | @AliasFor("value") 44 | String name() default ""; 45 | 46 | /** 47 | * Effectively an alias for {@link #name()}. 48 | */ 49 | @AliasFor("name") 50 | String value() default ""; 51 | 52 | } 53 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/data/federation/RepresentationNotResolvedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.federation; 18 | 19 | 20 | import java.util.Map; 21 | 22 | import org.springframework.graphql.data.method.HandlerMethod; 23 | 24 | /** 25 | * Specialization of {@link RepresentationException} that indicates a resolver 26 | * returned {@code null} or completed empty. 27 | * 28 | * @author Rossen Stoyanchev 29 | * @since 1.3.0 30 | */ 31 | @SuppressWarnings("serial") 32 | public class RepresentationNotResolvedException extends RepresentationException { 33 | 34 | public RepresentationNotResolvedException(Map representation, HandlerMethod handlerMethod) { 35 | super(representation, handlerMethod, "Entity fetcher returned null or completed empty"); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/data/federation/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Integration for Apollo federation that provides a 19 | * {@link org.springframework.graphql.data.federation.FederationSchemaFactory} to 20 | * set up the schema with, and supports the fetching of federated types 21 | * via {@link org.springframework.graphql.data.federation.EntityMapping @EntityMapping} 22 | * controller methods. 23 | */ 24 | @NullMarked 25 | package org.springframework.graphql.data.federation; 26 | 27 | import org.jspecify.annotations.NullMarked; 28 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/Arguments.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.method.annotation; 18 | 19 | import java.lang.annotation.Documented; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | import graphql.schema.DataFetchingEnvironment; 26 | 27 | /** 28 | * Analogous to {@link Argument} but binding with the full 29 | * {@link DataFetchingEnvironment#getArgument(String) arguments} map. 30 | * 31 | * @author Rossen Stoyanchev 32 | * @since 1.0.0 33 | */ 34 | @Target(ElementType.PARAMETER) 35 | @Retention(RetentionPolicy.RUNTIME) 36 | @Documented 37 | public @interface Arguments { 38 | 39 | } 40 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/MutationMapping.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.method.annotation; 18 | 19 | import java.lang.annotation.Documented; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | import org.springframework.core.annotation.AliasFor; 26 | 27 | /** 28 | * {@code @MutationMapping} is a composed annotation that acts as a 29 | * shortcut for {@link SchemaMapping @SchemaMapping} with 30 | * {@code typeName="Mutation"}. 31 | * 32 | * @author Rossen Stoyanchev 33 | * @since 1.0.0 34 | */ 35 | @Target(ElementType.METHOD) 36 | @Retention(RetentionPolicy.RUNTIME) 37 | @Documented 38 | @SchemaMapping(typeName = "Mutation") 39 | public @interface MutationMapping { 40 | 41 | /** 42 | * Alias for {@link SchemaMapping#field()}. 43 | */ 44 | @AliasFor(annotation = SchemaMapping.class, attribute = "field") 45 | String name() default ""; 46 | 47 | /** 48 | * Alias for {@link SchemaMapping#field()}. 49 | */ 50 | @AliasFor(annotation = SchemaMapping.class, attribute = "field") 51 | String value() default ""; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/QueryMapping.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.method.annotation; 18 | 19 | import java.lang.annotation.Documented; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | import org.springframework.core.annotation.AliasFor; 26 | 27 | /** 28 | * {@code @QueryMapping} is a composed annotation that acts as a 29 | * shortcut for {@link SchemaMapping @SchemaMapping} with 30 | * {@code typeName="Query"}. 31 | * 32 | * @author Rossen Stoyanchev 33 | * @since 1.0.0 34 | */ 35 | @Target(ElementType.METHOD) 36 | @Retention(RetentionPolicy.RUNTIME) 37 | @Documented 38 | @SchemaMapping(typeName = "Query") 39 | public @interface QueryMapping { 40 | 41 | /** 42 | * Alias for {@link SchemaMapping#field()}. 43 | */ 44 | @AliasFor(annotation = SchemaMapping.class, attribute = "field") 45 | String name() default ""; 46 | 47 | /** 48 | * Alias for {@link SchemaMapping#field()}. 49 | */ 50 | @AliasFor(annotation = SchemaMapping.class, attribute = "field") 51 | String value() default ""; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/SubscriptionMapping.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.method.annotation; 18 | 19 | import java.lang.annotation.Documented; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | import org.springframework.core.annotation.AliasFor; 26 | 27 | /** 28 | * {@code @SubscriptionMapping} is a composed annotation that acts as a 29 | * shortcut for {@link SchemaMapping @SchemaMapping} with 30 | * {@code typeName="Subscription"}. 31 | * 32 | * @author Rossen Stoyanchev 33 | * @since 1.0.0 34 | */ 35 | @Target(ElementType.METHOD) 36 | @Retention(RetentionPolicy.RUNTIME) 37 | @Documented 38 | @SchemaMapping(typeName = "Subscription") 39 | public @interface SubscriptionMapping { 40 | 41 | /** 42 | * Alias for {@link SchemaMapping#field()}. 43 | */ 44 | @AliasFor(annotation = SchemaMapping.class, attribute = "field") 45 | String name() default ""; 46 | 47 | /** 48 | * Alias for {@link SchemaMapping#field()}. 49 | */ 50 | @AliasFor(annotation = SchemaMapping.class, attribute = "field") 51 | String value() default ""; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Annotations for binding data fetching methods to GraphQL schema queries, 19 | * mutations, subscriptions, and fields. 20 | */ 21 | @NullMarked 22 | package org.springframework.graphql.data.method.annotation; 23 | 24 | import org.jspecify.annotations.NullMarked; 25 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/ArgumentValueValueExtractor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.method.annotation.support; 18 | 19 | import jakarta.validation.valueextraction.ExtractedValue; 20 | import jakarta.validation.valueextraction.UnwrapByDefault; 21 | import jakarta.validation.valueextraction.ValueExtractor; 22 | 23 | import org.springframework.graphql.data.ArgumentValue; 24 | 25 | /** 26 | * {@link ValueExtractor} that enables {@code @Valid} with {@link ArgumentValue}, 27 | * and helps to extract the value from it. 28 | * 29 | * @author Rossen Stoyanchev 30 | * @since 1.2.2 31 | */ 32 | @UnwrapByDefault 33 | public final class ArgumentValueValueExtractor implements ValueExtractor> { 34 | 35 | @Override 36 | public void extractValues(ArgumentValue argumentValue, ValueReceiver receiver) { 37 | if (!argumentValue.isOmitted()) { 38 | receiver.value(null, argumentValue.value()); 39 | } 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/ContinuationHandlerMethodArgumentResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2021 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.method.annotation.support; 18 | 19 | import graphql.schema.DataFetchingEnvironment; 20 | import org.jspecify.annotations.Nullable; 21 | 22 | import org.springframework.core.MethodParameter; 23 | import org.springframework.graphql.data.method.HandlerMethodArgumentResolver; 24 | 25 | /** 26 | * No-op resolver for method arguments of type {@link kotlin.coroutines.Continuation}. 27 | * 28 | * @author Koen Punt 29 | * @since 1.0.0 30 | */ 31 | public class ContinuationHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver { 32 | 33 | @Override 34 | public boolean supportsParameter(MethodParameter parameter) { 35 | return "kotlin.coroutines.Continuation".equals(parameter.getParameterType().getName()); 36 | } 37 | 38 | @Override 39 | public @Nullable Object resolveArgument(MethodParameter parameter, DataFetchingEnvironment environment) { 40 | return null; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Resolvers for method parameters of annotated handler methods. 19 | */ 20 | 21 | @NullMarked 22 | package org.springframework.graphql.data.method.annotation.support; 23 | 24 | import org.jspecify.annotations.NullMarked; 25 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/data/method/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Support for DataFetcher's based on handler methods typically annotated with 19 | * {@link org.springframework.graphql.data.method.annotation.SchemaMapping} 20 | * annotations. 21 | */ 22 | @NullMarked 23 | package org.springframework.graphql.data.method; 24 | 25 | import org.jspecify.annotations.NullMarked; 26 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/data/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Support for various ways to implement {@link graphql.schema.DataFetcher}s. 19 | */ 20 | @NullMarked 21 | package org.springframework.graphql.data; 22 | 23 | import org.jspecify.annotations.NullMarked; 24 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/data/pagination/Base64CursorEncoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.pagination; 18 | 19 | 20 | import java.nio.charset.Charset; 21 | import java.nio.charset.StandardCharsets; 22 | import java.util.Base64; 23 | 24 | 25 | /** 26 | * {@link CursorEncoder} that applies Base 64 encoding and decoding. 27 | * 28 | *

To create an instance, use {@link CursorEncoder#base64()}. 29 | * 30 | * @author Rossen Stoyanchev 31 | */ 32 | final class Base64CursorEncoder implements CursorEncoder { 33 | 34 | private final Charset charset = StandardCharsets.UTF_8; 35 | 36 | 37 | @Override 38 | public String encode(String cursor) { 39 | byte[] bytes = Base64.getEncoder().encode(cursor.getBytes(this.charset)); 40 | return new String(bytes, this.charset); 41 | } 42 | 43 | @Override 44 | public String decode(String cursor) { 45 | byte[] bytes = Base64.getDecoder().decode(cursor.getBytes(this.charset)); 46 | return new String(bytes, this.charset); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/data/pagination/ConnectionAdapterSupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.pagination; 18 | 19 | import org.springframework.util.Assert; 20 | 21 | /** 22 | * Convenient base class for implementations of 23 | * {@link org.springframework.graphql.data.pagination.ConnectionAdapter}. 24 | * 25 | * @param

the position type 26 | * @author Rossen Stoyanchev 27 | * @since 1.2.0 28 | */ 29 | public class ConnectionAdapterSupport

{ 30 | 31 | private final CursorStrategy

cursorStrategy; 32 | 33 | 34 | /** 35 | * Constructor with a {@link CursorStrategy} to use. 36 | * @param cursorStrategy the cursor strategy to use 37 | */ 38 | protected ConnectionAdapterSupport(CursorStrategy

cursorStrategy) { 39 | Assert.notNull(cursorStrategy, "CursorStrategy is required"); 40 | this.cursorStrategy = cursorStrategy; 41 | } 42 | 43 | 44 | /** 45 | * Return the configured {@link CursorStrategy}. 46 | */ 47 | public CursorStrategy

getCursorStrategy() { 48 | return this.cursorStrategy; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/data/pagination/CursorEncoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.pagination; 18 | 19 | /** 20 | * Strategy to encode and decode a String cursor to make it opaque for clients. 21 | * Typically applied to a {@link CursorStrategy} via 22 | * {@link CursorStrategy#withEncoder(CursorStrategy, CursorEncoder)}. 23 | * 24 | * @author Rossen Stoyanchev 25 | * @since 1.2.0 26 | */ 27 | public interface CursorEncoder { 28 | 29 | /** 30 | * Encode the given cursor value for external use. 31 | * @param cursor the cursor to encode 32 | * @return the encoded value 33 | */ 34 | String encode(String cursor); 35 | 36 | /** 37 | * Decode the given cursor from external input. 38 | * @param cursor the raw cursor to decode 39 | * @return the decoded value 40 | */ 41 | String decode(String cursor); 42 | 43 | 44 | /** 45 | * Return a {@code CursorEncoder} for Base64 encoding and decoding. 46 | */ 47 | static CursorEncoder base64() { 48 | return new Base64CursorEncoder(); 49 | } 50 | 51 | /** 52 | * Return a {@code CursorEncoder} that does not encode nor decode. 53 | */ 54 | static CursorEncoder noOpEncoder() { 55 | return new NoOpCursorEncoder(); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/data/pagination/NoOpCursorEncoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.pagination; 18 | 19 | /** 20 | * {@link CursorEncoder} that leaves the cursor value unchanged. 21 | * 22 | *

To create an instance, use {@link CursorEncoder#noOpEncoder()}. 23 | * 24 | * @author Rossen Stoyanchev 25 | */ 26 | final class NoOpCursorEncoder implements CursorEncoder { 27 | 28 | @Override 29 | public String encode(String cursor) { 30 | return cursor; 31 | } 32 | 33 | @Override 34 | public String decode(String cursor) { 35 | return cursor; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/data/pagination/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Core contracts and generic infrastructure classes for pagination. 19 | */ 20 | @NullMarked 21 | package org.springframework.graphql.data.pagination; 22 | 23 | import org.jspecify.annotations.NullMarked; 24 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/data/query/SortStrategy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.query; 18 | 19 | 20 | import graphql.schema.DataFetchingEnvironment; 21 | 22 | import org.springframework.data.domain.Sort; 23 | 24 | /** 25 | * Strategy to extract {@link Sort} details from GraphQL arguments. 26 | * 27 | * @author Rossen Stoyanchev 28 | * @since 1.2.0 29 | */ 30 | public interface SortStrategy { 31 | 32 | /** 33 | * Return a {@link Sort} instance by extracting the sort information from 34 | * GraphQL arguments, or {@link Sort#unsorted()} otherwise. 35 | * @param environment the data fetching environment 36 | */ 37 | Sort extract(DataFetchingEnvironment environment); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/data/query/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * {@link graphql.schema.DataFetcher} implementations built on Spring Data 19 | * extensions such as Query by Example and Querydsl. 20 | * 21 | * @see 22 | * Spring Data Query By Example 23 | * @see 24 | * Spring Data Querydsl 25 | */ 26 | @NullMarked 27 | package org.springframework.graphql.data.query; 28 | 29 | import org.jspecify.annotations.NullMarked; 30 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/execution/ContextSnapshotFactoryHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.execution; 18 | 19 | import io.micrometer.context.ContextSnapshotFactory; 20 | 21 | /** 22 | * Helper to use a single {@link ContextSnapshotFactory} instance by saving and 23 | * obtaining it to and from Reactor and GraphQL contexts. 24 | * 25 | * @author Rossen Stoyanchev 26 | * @since 1.3.0 27 | * @deprecated since 1.3.5 in favor of {@link ContextPropagationHelper}. 28 | */ 29 | @Deprecated(since = "1.3.5", forRemoval = true) 30 | public abstract class ContextSnapshotFactoryHelper extends ContextPropagationHelper { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/execution/ExternalSchemaGraphQlSourceBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.execution; 18 | 19 | 20 | import graphql.schema.GraphQLSchema; 21 | 22 | import org.springframework.util.Assert; 23 | 24 | 25 | /** 26 | * {@link GraphQlSource.Builder} that uses an externally prepared 27 | * {@link GraphQLSchema}. 28 | * 29 | * @author Rossen Stoyanchev 30 | */ 31 | final class ExternalSchemaGraphQlSourceBuilder 32 | extends AbstractGraphQlSourceBuilder 33 | implements GraphQlSource.Builder { 34 | 35 | private final GraphQLSchema schema; 36 | 37 | 38 | ExternalSchemaGraphQlSourceBuilder(GraphQLSchema schema) { 39 | Assert.notNull(schema, "GraphQLSchema is required"); 40 | this.schema = schema; 41 | } 42 | 43 | 44 | @Override 45 | protected GraphQLSchema initGraphQlSchema() { 46 | return this.schema; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/execution/MissingSchemaException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2021 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.execution; 18 | 19 | import org.springframework.core.NestedRuntimeException; 20 | 21 | /** 22 | * Indicates that no GraphQL schema definition was configured on the {@link GraphQlSource.Builder}. 23 | * 24 | * @author Brian Clozel 25 | * @since 1.0.0 26 | */ 27 | @SuppressWarnings("serial") 28 | public class MissingSchemaException extends NestedRuntimeException { 29 | 30 | public MissingSchemaException() { 31 | super("No GraphQL schema definition was configured."); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/execution/TypeDefinitionConfigurer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.execution; 18 | 19 | import graphql.schema.GraphQLSchema; 20 | import graphql.schema.idl.TypeDefinitionRegistry; 21 | 22 | /** 23 | * Callback that allows customizing the {@link TypeDefinitionRegistry} created 24 | * from parsed schema files. It allows adding schema types programmatically 25 | * before the registry is used to create {@link GraphQLSchema}. 26 | * 27 | * @author Rossen Stoyanchev 28 | * @since 1.2.0 29 | */ 30 | public interface TypeDefinitionConfigurer { 31 | 32 | /** 33 | * Customize the given {@link TypeDefinitionRegistry}. 34 | * @param registry the registry to customize 35 | */ 36 | void configure(TypeDefinitionRegistry registry); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/execution/TypeVisitorHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.execution; 18 | 19 | import graphql.schema.GraphQLNamedType; 20 | import graphql.schema.GraphQLSchema; 21 | 22 | /** 23 | * Helps {@link graphql.schema.GraphQLTypeVisitor}s to recognize whether a type 24 | * is the subscription type. Exposed as a variable in 25 | * {@link graphql.util.TraverserContext}. 26 | * 27 | * @author Rossen Stoyanchev 28 | * @since 1.2.1 29 | */ 30 | public interface TypeVisitorHelper { 31 | 32 | /** 33 | * Whether the given type is the subscription type. 34 | * @param type the GraphQL type to check 35 | */ 36 | boolean isSubscriptionType(GraphQLNamedType type); 37 | 38 | 39 | /** 40 | * Create an instance with the given {@link GraphQLSchema}. 41 | * @param schema the GraphQL schema to use 42 | */ 43 | static TypeVisitorHelper create(GraphQLSchema schema) { 44 | String name = (schema.getSubscriptionType() != null) ? schema.getSubscriptionType().getName() : null; 45 | return (candidate) -> candidate.getName().equals(name); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/execution/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Support for GraphQL request execution, including abstractions to configure and invoke 19 | * {@link graphql.GraphQL}. 20 | */ 21 | @NullMarked 22 | package org.springframework.graphql.execution; 23 | 24 | import org.jspecify.annotations.NullMarked; 25 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/observation/DataFetcherObservationConvention.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.observation; 18 | 19 | import io.micrometer.observation.Observation; 20 | import io.micrometer.observation.ObservationConvention; 21 | 22 | /** 23 | * Interface for an {@link ObservationConvention} 24 | * for {@link GraphQlObservationDocumentation#DATA_FETCHER data fetching observations}. 25 | * 26 | * @author Brian Clozel 27 | * @since 1.1.0 28 | */ 29 | public interface DataFetcherObservationConvention extends ObservationConvention { 30 | 31 | 32 | @Override 33 | default boolean supportsContext(Observation.Context context) { 34 | return context instanceof DataFetcherObservationContext; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/observation/DataLoaderObservationConvention.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.observation; 18 | 19 | import io.micrometer.observation.Observation; 20 | import io.micrometer.observation.ObservationConvention; 21 | 22 | /** 23 | * Interface for an {@link ObservationConvention} 24 | * for {@link GraphQlObservationDocumentation#DATA_LOADER data loading observations}. 25 | * 26 | * @author Brian Clozel 27 | * @since 1.4.0 28 | */ 29 | public interface DataLoaderObservationConvention extends ObservationConvention { 30 | 31 | @Override 32 | default boolean supportsContext(Observation.Context context) { 33 | return context instanceof DataLoaderObservationContext; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/observation/ExecutionRequestObservationConvention.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.observation; 18 | 19 | import io.micrometer.observation.Observation; 20 | import io.micrometer.observation.ObservationConvention; 21 | 22 | /** 23 | * Interface for an {@link ObservationConvention} for {@link GraphQlObservationDocumentation#EXECUTION_REQUEST GraphQL requests}. 24 | * 25 | * @author Brian Clozel 26 | * @since 1.1.0 27 | */ 28 | public interface ExecutionRequestObservationConvention extends ObservationConvention { 29 | 30 | @Override 31 | default boolean supportsContext(Observation.Context context) { 32 | return context instanceof ExecutionRequestObservationContext; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/observation/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Support for GraphQL {@link io.micrometer.observation.Observation observability}. 19 | */ 20 | @NullMarked 21 | package org.springframework.graphql.observation; 22 | 23 | import org.jspecify.annotations.NullMarked; 24 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Top level abstractions for processing GraphQL requests. 19 | */ 20 | @NullMarked 21 | package org.springframework.graphql; 22 | 23 | import org.jspecify.annotations.NullMarked; 24 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/server/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Server transports handling GraphQL requests over the HTTP, WebSocket, and RSocket. 19 | */ 20 | @NullMarked 21 | package org.springframework.graphql.server; 22 | 23 | import org.jspecify.annotations.NullMarked; 24 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/server/support/AuthenticationExtractor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.server.support; 18 | 19 | import java.util.Map; 20 | 21 | import reactor.core.publisher.Mono; 22 | 23 | import org.springframework.security.core.Authentication; 24 | 25 | /** 26 | * Strategy to extract an {@link Authentication} from the payload of a 27 | * {@code "connection_init"} GraphQL over WebSocket message. 28 | * 29 | * @author Joshua Cummings 30 | * @author Rossen Stoyanchev 31 | * @since 1.3.0 32 | */ 33 | public interface AuthenticationExtractor { 34 | 35 | /** 36 | * Return the authentication contained in the given payload, or an empty {@code Mono}. 37 | * @param payload the payload to extract the authentication value from 38 | */ 39 | Mono getAuthentication(Map payload); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/server/support/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Support classes for Web transports. 19 | */ 20 | @NullMarked 21 | package org.springframework.graphql.server.support; 22 | 23 | import org.jspecify.annotations.NullMarked; 24 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/server/webflux/SchemaHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2021 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.server.webflux; 18 | 19 | import graphql.schema.idl.SchemaPrinter; 20 | import reactor.core.publisher.Mono; 21 | 22 | import org.springframework.graphql.execution.GraphQlSource; 23 | import org.springframework.http.MediaType; 24 | import org.springframework.web.reactive.function.server.ServerRequest; 25 | import org.springframework.web.reactive.function.server.ServerResponse; 26 | 27 | /** 28 | * Spring WebFlux functional handler that renders the 29 | * {@link graphql.schema.GraphQLSchema} printed via {@link SchemaPrinter}. 30 | * 31 | * @author Rossen Stoyanchev 32 | * @since 1.0.0 33 | */ 34 | public class SchemaHandler { 35 | 36 | private final GraphQlSource graphQlSource; 37 | 38 | private final SchemaPrinter printer = new SchemaPrinter(); 39 | 40 | 41 | public SchemaHandler(GraphQlSource graphQlSource) { 42 | this.graphQlSource = graphQlSource; 43 | } 44 | 45 | 46 | public Mono handleRequest(ServerRequest request) { 47 | return ServerResponse.ok() 48 | .contentType(MediaType.TEXT_PLAIN) 49 | .bodyValue(this.printer.print(this.graphQlSource.schema())); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/server/webflux/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * HTTP and WebSocket handlers for use in a Spring WebFlux application. 19 | */ 20 | @NullMarked 21 | package org.springframework.graphql.server.webflux; 22 | 23 | import org.jspecify.annotations.NullMarked; 24 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/server/webmvc/SchemaHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2021 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.server.webmvc; 18 | 19 | import graphql.schema.idl.SchemaPrinter; 20 | 21 | import org.springframework.graphql.execution.GraphQlSource; 22 | import org.springframework.http.MediaType; 23 | import org.springframework.web.servlet.function.ServerRequest; 24 | import org.springframework.web.servlet.function.ServerResponse; 25 | 26 | /** 27 | * Spring MVC functional handler that renders the 28 | * {@link graphql.schema.GraphQLSchema} printed via {@link SchemaPrinter}. 29 | * 30 | * @author Rossen Stoyanchev 31 | * @since 1.0.0 32 | */ 33 | public class SchemaHandler { 34 | 35 | private final GraphQlSource graphQlSource; 36 | 37 | private final SchemaPrinter printer = new SchemaPrinter(); 38 | 39 | 40 | public SchemaHandler(GraphQlSource graphQlSource) { 41 | this.graphQlSource = graphQlSource; 42 | } 43 | 44 | 45 | public ServerResponse handleRequest(ServerRequest request) { 46 | return ServerResponse.ok() 47 | .contentType(MediaType.TEXT_PLAIN) 48 | .body(this.printer.print(this.graphQlSource.schema())); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/server/webmvc/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * HTTP and WebSocket handlers for use in a Spring WebMvc application. 19 | */ 20 | @NullMarked 21 | package org.springframework.graphql.server.webmvc; 22 | 23 | import org.jspecify.annotations.NullMarked; 24 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/support/DocumentSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.support; 18 | 19 | import reactor.core.publisher.Mono; 20 | 21 | /** 22 | * Strategy to locate a GraphQL document by a name. 23 | * 24 | * @author Rossen Stoyanchev 25 | * @since 1.0.0 26 | */ 27 | public interface DocumentSource { 28 | 29 | /** 30 | * Return the document that matches the given name. 31 | * @param name the name to use for the lookup 32 | * @return {@code Mono} that completes either with the document content or 33 | * with an error, but never empty. 34 | */ 35 | Mono getDocument(String name); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /spring-graphql/src/main/java/org/springframework/graphql/support/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Support classes for Spring GraphQL. 19 | */ 20 | @NullMarked 21 | package org.springframework.graphql.support; 22 | 23 | import org.jspecify.annotations.NullMarked; 24 | -------------------------------------------------------------------------------- /spring-graphql/src/main/resources/META-INF/native-image/org.springframework.graphql/spring-graphql/reflect-config.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "org.springframework.graphql.data.method.annotation.support.AnnotatedControllerExceptionResolver$MethodResolver", 4 | "allDeclaredMethods": true, 5 | "condition": { 6 | "typeReachable": "org.springframework.graphql.data.method.annotation.support.AnnotatedControllerExceptionResolver" 7 | } 8 | }, 9 | { 10 | "name":"org.springframework.graphql.server.support.GraphQlWebSocketMessage", 11 | "allDeclaredFields":true, 12 | "allDeclaredMethods":true, 13 | "allDeclaredConstructors":true, 14 | "condition": { 15 | "typeReachable": "org.springframework.graphql.client.CodecDelegate" 16 | } 17 | }, 18 | { 19 | "name":"org.springframework.graphql.server.support.GraphQlWebSocketMessage", 20 | "allDeclaredFields":true, 21 | "allDeclaredMethods":true, 22 | "allDeclaredConstructors":true, 23 | "condition": { 24 | "typeReachable": "org.springframework.graphql.server.webflux.WebSocketCodecDelegate" 25 | } 26 | }, 27 | { 28 | "name":"org.springframework.graphql.server.support.SerializableGraphQlRequest", 29 | "allDeclaredFields":true, 30 | "allDeclaredMethods":true, 31 | "allDeclaredConstructors":true, 32 | "condition": { 33 | "typeReachable": "org.springframework.graphql.server.webflux.GraphQlHttpHandler" 34 | } 35 | }, 36 | { 37 | "name":"org.springframework.graphql.server.support.SerializableGraphQlRequest", 38 | "allDeclaredFields":true, 39 | "allDeclaredMethods":true, 40 | "allDeclaredConstructors":true, 41 | "condition": { 42 | "typeReachable": "org.springframework.graphql.server.webmvc.GraphQlHttpHandler" 43 | } 44 | } 45 | ] 46 | -------------------------------------------------------------------------------- /spring-graphql/src/main/resources/META-INF/native-image/org.springframework.graphql/spring-graphql/resource-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "bundles": [], 3 | "resources": { 4 | "includes": [ 5 | { 6 | "pattern": "\\Qgraphql-documents\/\\E.*\\Q.graphql\\E", 7 | "condition": { 8 | "typeReachable": "org.springframework.graphql.client.GraphQlClient" 9 | } 10 | }, 11 | { 12 | "pattern": "\\Qgraphql-documents\/\\E.*\\Q.gql\\E", 13 | "condition": { 14 | "typeReachable": "org.springframework.graphql.client.GraphQlClient" 15 | } 16 | } 17 | ] 18 | } 19 | } -------------------------------------------------------------------------------- /spring-graphql/src/main/resources/META-INF/services/io.micrometer.context.ContextAccessor: -------------------------------------------------------------------------------- 1 | org.springframework.graphql.execution.GraphQlContextAccessor -------------------------------------------------------------------------------- /spring-graphql/src/main/resources/META-INF/services/io.micrometer.context.ThreadLocalAccessor: -------------------------------------------------------------------------------- 1 | org.springframework.graphql.execution.SecurityContextThreadLocalAccessor -------------------------------------------------------------------------------- /spring-graphql/src/main/resources/META-INF/services/jakarta.validation.valueextraction.ValueExtractor: -------------------------------------------------------------------------------- 1 | org.springframework.graphql.data.method.annotation.support.ArgumentValueValueExtractor -------------------------------------------------------------------------------- /spring-graphql/src/main/resources/META-INF/spring/aot.factories: -------------------------------------------------------------------------------- 1 | org.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor=org.springframework.graphql.data.method.annotation.support.SchemaMappingBeanFactoryInitializationAotProcessor -------------------------------------------------------------------------------- /spring-graphql/src/test/java/org/springframework/graphql/Author.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2021 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql; 18 | 19 | public class Author { 20 | 21 | Long id; 22 | 23 | String firstName; 24 | 25 | String lastName; 26 | 27 | public Author() { 28 | } 29 | 30 | public Author(Long id, String firstName, String lastName) { 31 | this.id = id; 32 | this.firstName = firstName; 33 | this.lastName = lastName; 34 | } 35 | 36 | 37 | public void setId(Long id) { 38 | this.id = id; 39 | } 40 | 41 | public Long getId() { 42 | return this.id; 43 | } 44 | 45 | public String getFirstName() { 46 | return this.firstName; 47 | } 48 | 49 | public void setFirstName(String firstName) { 50 | this.firstName = firstName; 51 | } 52 | 53 | public String getLastName() { 54 | return this.lastName; 55 | } 56 | 57 | public void setLastName(String lastName) { 58 | this.lastName = lastName; 59 | } 60 | 61 | public String getFullName() { 62 | return this.firstName + " " + this.lastName; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /spring-graphql/src/test/java/org/springframework/graphql/Book.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2021 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql; 18 | 19 | public class Book { 20 | 21 | Long id; 22 | 23 | String name; 24 | 25 | Long authorId; 26 | 27 | Author author; 28 | 29 | public String publicField; 30 | 31 | public Book() { 32 | } 33 | 34 | public Book(Long id, String name, Long authorId) { 35 | this.id = id; 36 | this.name = name; 37 | this.authorId = authorId; 38 | this.author = null; 39 | } 40 | 41 | public Book(Long id, String name, Author author) { 42 | this.id = id; 43 | this.name = name; 44 | this.authorId = author.getId(); 45 | this.author = author; 46 | } 47 | 48 | public Long getId() { 49 | return this.id; 50 | } 51 | 52 | public void setId(Long id) { 53 | this.id = id; 54 | } 55 | 56 | public String getName() { 57 | return this.name; 58 | } 59 | 60 | public void setName(String name) { 61 | this.name = name; 62 | } 63 | 64 | public Long getAuthorId() { 65 | return this.authorId; 66 | } 67 | 68 | public Author getAuthor() { 69 | return this.author; 70 | } 71 | 72 | public void setAuthor(Author author) { 73 | this.author = author; 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /spring-graphql/src/test/java/org/springframework/graphql/BookCriteria.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2021 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql; 18 | 19 | public class BookCriteria { 20 | 21 | private Long id; 22 | 23 | private String author; 24 | 25 | 26 | public Long getId() { 27 | return this.id; 28 | } 29 | 30 | public void setId(Long id) { 31 | this.id = id; 32 | } 33 | 34 | public String getAuthor() { 35 | return this.author; 36 | } 37 | 38 | public void setAuthor(String author) { 39 | this.author = author; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /spring-graphql/src/test/java/org/springframework/graphql/DefaultExecutionGraphQlRequestTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql; 18 | 19 | import java.util.Locale; 20 | 21 | import graphql.execution.ExecutionId; 22 | import org.junit.jupiter.api.Test; 23 | 24 | import org.springframework.graphql.support.DefaultExecutionGraphQlRequest; 25 | 26 | import static org.assertj.core.api.Assertions.assertThat; 27 | 28 | /** 29 | * Tests for {@link DefaultExecutionGraphQlRequest}. 30 | * 31 | * @author Brian Clozel 32 | */ 33 | class DefaultExecutionGraphQlRequestTests { 34 | 35 | private final DefaultExecutionGraphQlRequest request = 36 | new DefaultExecutionGraphQlRequest("greeting", "Greeting", null, null, "id", null); 37 | 38 | 39 | @Test 40 | void shouldUseRequestId() { 41 | assertThat(this.request.toExecutionInput().getExecutionId()).isEqualTo(ExecutionId.from("id")); 42 | } 43 | 44 | @Test 45 | void shouldUseExecutionId() { 46 | ExecutionId customId = ExecutionId.from("customId"); 47 | this.request.executionId(customId); 48 | assertThat(this.request.toExecutionInput().getExecutionId()).isEqualTo(customId); 49 | } 50 | 51 | @Test 52 | void shouldHaveDefaultLocale() { 53 | assertThat(this.request.getLocale()).isEqualTo(Locale.getDefault()); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /spring-graphql/src/test/java/org/springframework/graphql/QAuthor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql; 18 | 19 | import com.querydsl.core.types.Path; 20 | import com.querydsl.core.types.PathMetadata; 21 | import com.querydsl.core.types.dsl.EntityPathBase; 22 | import com.querydsl.core.types.dsl.NumberPath; 23 | import com.querydsl.core.types.dsl.StringPath; 24 | 25 | import static com.querydsl.core.types.PathMetadataFactory.forVariable; 26 | 27 | /** 28 | * QAuthor is a Querydsl query type for Author 29 | */ 30 | public class QAuthor extends EntityPathBase { 31 | private static final long serialVersionUID = 1773522017L; 32 | public static final QAuthor author = new QAuthor("author"); 33 | public final StringPath firstName = createString("firstName"); 34 | public final NumberPath id = createNumber("id", Long.class); 35 | public final StringPath lastName = createString("lastName"); 36 | 37 | public QAuthor(String variable) { 38 | super(Author.class, forVariable(variable)); 39 | } 40 | 41 | public QAuthor(Path path) { 42 | super(path.getType(), path.getMetadata()); 43 | } 44 | 45 | public QAuthor(PathMetadata metadata) { 46 | super(Author.class, metadata); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /spring-graphql/src/test/java/org/springframework/graphql/client/MovieCharacter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.client; 18 | 19 | import org.jspecify.annotations.Nullable; 20 | 21 | import org.springframework.util.ObjectUtils; 22 | 23 | 24 | public class MovieCharacter { 25 | 26 | @Nullable 27 | private String name; 28 | 29 | 30 | public void setName(String name) { 31 | this.name = name; 32 | } 33 | 34 | @Nullable 35 | public String getName() { 36 | return this.name; 37 | } 38 | 39 | 40 | public static MovieCharacter create(String name) { 41 | MovieCharacter character = new MovieCharacter(); 42 | character.setName(name); 43 | return character; 44 | } 45 | 46 | 47 | @Override 48 | public boolean equals(Object other) { 49 | if (this == other) { 50 | return true; 51 | } 52 | if (other == null || getClass() != other.getClass()) { 53 | return false; 54 | } 55 | return ObjectUtils.nullSafeEquals(this.name, ((MovieCharacter) other).name); 56 | } 57 | 58 | @Override 59 | public int hashCode() { 60 | return (this.name != null) ? this.name.hashCode() : super.hashCode(); 61 | } 62 | 63 | @Override 64 | public String toString() { 65 | return "MovieCharacter[name='" + this.name + "']"; 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /spring-graphql/src/test/java/org/springframework/graphql/data/pagination/Base64CursorEncoderTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.pagination; 18 | 19 | import org.junit.jupiter.api.Test; 20 | 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | 23 | /** 24 | * Unit tests for {@link Base64CursorEncoder}. 25 | * 26 | * @author Rossen Stoyanchev 27 | */ 28 | class Base64CursorEncoderTests { 29 | 30 | private final Base64CursorEncoder encoder = new Base64CursorEncoder(); 31 | 32 | 33 | @Test 34 | void encodeAndDecode() { 35 | testEncodeAndDecode("O_43", "T180Mw=="); 36 | testEncodeAndDecode("K_{\"firstName\":\"Joseph\",\"id\":103}", "S197ImZpcnN0TmFtZSI6Ikpvc2VwaCIsImlkIjoxMDN9"); 37 | } 38 | 39 | private void testEncodeAndDecode(String decoded, String encoded) { 40 | assertThat(this.encoder.encode(decoded)).isEqualTo(encoded); 41 | assertThat(this.encoder.decode(encoded)).isEqualTo(decoded); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /spring-graphql/src/test/java/org/springframework/graphql/data/query/Book.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2021 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.query; 18 | 19 | import org.springframework.data.annotation.Id; 20 | import org.springframework.graphql.Author; 21 | 22 | public class Book { 23 | 24 | @Id 25 | Long id; 26 | 27 | String name; 28 | 29 | Author author; 30 | 31 | public Book() { 32 | } 33 | 34 | public Book(Long id, String name, Author author) { 35 | this.id = id; 36 | this.name = name; 37 | this.author = author; 38 | } 39 | 40 | public Long getId() { 41 | return this.id; 42 | } 43 | 44 | public void setId(Long id) { 45 | this.id = id; 46 | } 47 | 48 | public String getName() { 49 | return this.name; 50 | } 51 | 52 | public void setName(String name) { 53 | this.name = name; 54 | } 55 | 56 | public Author getAuthor() { 57 | return this.author; 58 | } 59 | 60 | public void setAuthor(Author author) { 61 | this.author = author; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /spring-graphql/src/test/java/org/springframework/graphql/data/query/jpa/Author.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2021 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.query.jpa; 18 | 19 | import jakarta.persistence.Entity; 20 | import jakarta.persistence.Id; 21 | 22 | @Entity 23 | public class Author { 24 | 25 | @Id 26 | Long id; 27 | 28 | String firstName; 29 | 30 | String lastName; 31 | 32 | public Author() { 33 | } 34 | 35 | public Author(Long id, String firstName, String lastName) { 36 | this.id = id; 37 | this.firstName = firstName; 38 | this.lastName = lastName; 39 | } 40 | 41 | public Long getId() { 42 | return this.id; 43 | } 44 | 45 | public void setId(Long id) { 46 | this.id = id; 47 | } 48 | 49 | public String getFirstName() { 50 | return this.firstName; 51 | } 52 | 53 | public void setFirstName(String firstName) { 54 | this.firstName = firstName; 55 | } 56 | 57 | public String getLastName() { 58 | return this.lastName; 59 | } 60 | 61 | public void setLastName(String lastName) { 62 | this.lastName = lastName; 63 | } 64 | 65 | public String getFullName() { 66 | return this.firstName + " " + this.lastName; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /spring-graphql/src/test/java/org/springframework/graphql/data/query/jpa/Book.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2021 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.query.jpa; 18 | 19 | import jakarta.persistence.CascadeType; 20 | import jakarta.persistence.Entity; 21 | import jakarta.persistence.Id; 22 | import jakarta.persistence.OneToOne; 23 | 24 | @Entity 25 | public class Book { 26 | 27 | @Id 28 | Long id; 29 | 30 | String name; 31 | 32 | @OneToOne(cascade = CascadeType.ALL) 33 | Author author = new Author(); 34 | 35 | public Book() { 36 | } 37 | 38 | public Book(Long id, String name, Author author) { 39 | this.id = id; 40 | this.name = name; 41 | this.author = author; 42 | } 43 | 44 | public Long getId() { 45 | return this.id; 46 | } 47 | 48 | public void setId(Long id) { 49 | this.id = id; 50 | } 51 | 52 | public String getName() { 53 | return this.name; 54 | } 55 | 56 | public void setName(String name) { 57 | this.name = name; 58 | } 59 | 60 | public Author getAuthor() { 61 | return this.author; 62 | } 63 | 64 | public void setAuthor(Author author) { 65 | this.author = author; 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /spring-graphql/src/test/java/org/springframework/graphql/data/query/jpa/BookJpaRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.query.jpa; 18 | 19 | import org.springframework.data.jpa.repository.JpaRepository; 20 | import org.springframework.graphql.data.GraphQlRepository; 21 | 22 | @GraphQlRepository 23 | public interface BookJpaRepository extends JpaRepository { 24 | } 25 | -------------------------------------------------------------------------------- /spring-graphql/src/test/java/org/springframework/graphql/data/query/jpa/BookProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.query.jpa; 18 | 19 | import org.springframework.beans.factory.annotation.Value; 20 | 21 | interface BookProjection { 22 | 23 | @Value("#{target.name + ' by ' + target.author.firstName + ' ' + target.author.lastName}") 24 | String getName(); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /spring-graphql/src/test/java/org/springframework/graphql/data/query/jpa/ProjectingBookJpaRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.query.jpa; 18 | 19 | import org.springframework.data.jpa.repository.JpaRepository; 20 | import org.springframework.graphql.data.GraphQlRepository; 21 | import org.springframework.graphql.data.query.QueryByExampleDataFetcher.Builder; 22 | import org.springframework.graphql.data.query.QueryByExampleDataFetcher.QueryByExampleBuilderCustomizer; 23 | 24 | @GraphQlRepository 25 | public interface ProjectingBookJpaRepository extends JpaRepository, QueryByExampleBuilderCustomizer { 26 | 27 | @Override 28 | default Builder customize(Builder builder) { 29 | return builder.projectAs(BookProjection.class); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-graphql/src/test/java/org/springframework/graphql/data/query/mongo/Author.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2021 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.query.mongo; 18 | 19 | import org.springframework.data.annotation.Id; 20 | 21 | public class Author { 22 | 23 | @Id 24 | String id; 25 | 26 | String firstName; 27 | 28 | String lastName; 29 | 30 | public Author() { 31 | } 32 | 33 | public Author(String id, String firstName, String lastName) { 34 | this.id = id; 35 | this.firstName = firstName; 36 | this.lastName = lastName; 37 | } 38 | 39 | public String getId() { 40 | return this.id; 41 | } 42 | 43 | public void setId(String id) { 44 | this.id = id; 45 | } 46 | 47 | public String getFirstName() { 48 | return this.firstName; 49 | } 50 | 51 | public void setFirstName(String firstName) { 52 | this.firstName = firstName; 53 | } 54 | 55 | public String getLastName() { 56 | return this.lastName; 57 | } 58 | 59 | public void setLastName(String lastName) { 60 | this.lastName = lastName; 61 | } 62 | 63 | public String getFullName() { 64 | return this.firstName + " " + this.lastName; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /spring-graphql/src/test/java/org/springframework/graphql/data/query/mongo/Book.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2021 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.query.mongo; 18 | 19 | import org.springframework.data.annotation.Id; 20 | 21 | public class Book { 22 | 23 | @Id 24 | String id; 25 | 26 | String name; 27 | 28 | Author author = new Author(); 29 | 30 | public Book() { 31 | } 32 | 33 | public Book(String id, String name, Author author) { 34 | this.id = id; 35 | this.name = name; 36 | this.author = author; 37 | } 38 | 39 | public String getId() { 40 | return this.id; 41 | } 42 | 43 | public void setId(String id) { 44 | this.id = id; 45 | } 46 | 47 | public String getName() { 48 | return this.name; 49 | } 50 | 51 | public void setName(String name) { 52 | this.name = name; 53 | } 54 | 55 | public Author getAuthor() { 56 | return this.author; 57 | } 58 | 59 | public void setAuthor(Author author) { 60 | this.author = author; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /spring-graphql/src/test/java/org/springframework/graphql/data/query/mongo/BookMongoRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.query.mongo; 18 | 19 | import org.springframework.data.mongodb.repository.MongoRepository; 20 | import org.springframework.graphql.data.GraphQlRepository; 21 | 22 | @GraphQlRepository 23 | public interface BookMongoRepository extends MongoRepository { 24 | } 25 | -------------------------------------------------------------------------------- /spring-graphql/src/test/java/org/springframework/graphql/data/query/mongo/BookReactiveMongoRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.query.mongo; 18 | 19 | import org.springframework.data.mongodb.repository.ReactiveMongoRepository; 20 | import org.springframework.graphql.data.GraphQlRepository; 21 | 22 | @GraphQlRepository 23 | public interface BookReactiveMongoRepository extends ReactiveMongoRepository { 24 | } 25 | -------------------------------------------------------------------------------- /spring-graphql/src/test/java/org/springframework/graphql/data/query/neo4j/Author.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.query.neo4j; 18 | 19 | import org.springframework.data.neo4j.core.schema.Id; 20 | import org.springframework.data.neo4j.core.schema.Node; 21 | 22 | /** 23 | * @author Gerrit Meier 24 | */ 25 | @Node 26 | public class Author { 27 | 28 | @Id 29 | String id; 30 | 31 | String firstName; 32 | 33 | String lastName; 34 | 35 | // needed for response mapping 36 | public Author() { 37 | 38 | } 39 | 40 | public Author(String id, String firstName, String lastName) { 41 | this.id = id; 42 | this.firstName = firstName; 43 | this.lastName = lastName; 44 | } 45 | 46 | public String getId() { 47 | return this.id; 48 | } 49 | 50 | public void setId(String id) { 51 | this.id = id; 52 | } 53 | 54 | public String getFirstName() { 55 | return this.firstName; 56 | } 57 | 58 | public void setFirstName(String firstName) { 59 | this.firstName = firstName; 60 | } 61 | 62 | public String getLastName() { 63 | return this.lastName; 64 | } 65 | 66 | public void setLastName(String lastName) { 67 | this.lastName = lastName; 68 | } 69 | 70 | public String getFullName() { 71 | return this.firstName + " " + this.lastName; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /spring-graphql/src/test/java/org/springframework/graphql/data/query/neo4j/Book.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.query.neo4j; 18 | 19 | import org.springframework.data.neo4j.core.schema.Id; 20 | import org.springframework.data.neo4j.core.schema.Node; 21 | import org.springframework.data.neo4j.core.schema.Relationship; 22 | 23 | @Node 24 | public class Book { 25 | 26 | @Id 27 | String id; 28 | 29 | String name; 30 | 31 | @Relationship("AUTHOR") 32 | Author author; 33 | 34 | // needed for response mapping 35 | public Book() { 36 | 37 | } 38 | 39 | public Book(String id, String name, Author author) { 40 | this.id = id; 41 | this.name = name; 42 | this.author = author; 43 | } 44 | 45 | public String getId() { 46 | return this.id; 47 | } 48 | 49 | public void setId(String id) { 50 | this.id = id; 51 | } 52 | 53 | public String getName() { 54 | return this.name; 55 | } 56 | 57 | public void setName(String name) { 58 | this.name = name; 59 | } 60 | 61 | public Author getAuthor() { 62 | return this.author; 63 | } 64 | 65 | public void setAuthor(Author author) { 66 | this.author = author; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /spring-graphql/src/test/java/org/springframework/graphql/data/query/neo4j/BookNeo4jRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.query.neo4j; 18 | 19 | import org.springframework.data.neo4j.repository.Neo4jRepository; 20 | import org.springframework.graphql.data.GraphQlRepository; 21 | 22 | /** 23 | * @author Gerrit Meier 24 | */ 25 | @GraphQlRepository 26 | public interface BookNeo4jRepository extends Neo4jRepository { 27 | } 28 | -------------------------------------------------------------------------------- /spring-graphql/src/test/java/org/springframework/graphql/data/query/neo4j/BookReactiveNeo4jRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.data.query.neo4j; 18 | 19 | import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository; 20 | import org.springframework.graphql.data.GraphQlRepository; 21 | 22 | /** 23 | * @author Gerrit Meier 24 | */ 25 | @GraphQlRepository 26 | public interface BookReactiveNeo4jRepository extends ReactiveNeo4jRepository { 27 | } 28 | -------------------------------------------------------------------------------- /spring-graphql/src/test/java/org/springframework/graphql/server/ConsumeOneAndNeverCompleteInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.server; 18 | 19 | import org.reactivestreams.Publisher; 20 | import reactor.core.publisher.Flux; 21 | import reactor.core.publisher.Mono; 22 | 23 | public class ConsumeOneAndNeverCompleteInterceptor implements WebGraphQlInterceptor { 24 | 25 | @Override 26 | public Mono intercept(WebGraphQlRequest request, Chain chain) { 27 | return chain.next(request).map(response -> response.transform(builder -> { 28 | Object originalData = response.getData(); 29 | if (originalData instanceof Publisher) { 30 | Flux updatedData = Flux.from((Publisher) originalData).take(1).concatWith(Flux.never()); 31 | builder.data(updatedData); 32 | } 33 | })); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-graphql/src/test/java/org/springframework/graphql/support/DefaultGraphQlRequestTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.support; 18 | 19 | import java.util.Map; 20 | 21 | import org.junit.jupiter.api.Test; 22 | 23 | import org.springframework.graphql.GraphQlRequest; 24 | 25 | import static org.assertj.core.api.Assertions.assertThat; 26 | 27 | /** 28 | * Tests for {@link DefaultGraphQlRequest}. 29 | * @author Brian Clozel 30 | */ 31 | class DefaultGraphQlRequestTests { 32 | 33 | @Test 34 | void requestAsMapShouldContainAllEntries() { 35 | 36 | String document = "query HeroNameAndFriends($episode: Episode) {" + 37 | " hero(episode: $episode) {" + 38 | " name" 39 | + " }" + 40 | "}"; 41 | 42 | Map variables = Map.of("episode", "JEDI"); 43 | Map extensions = Map.of("myExtension", "value"); 44 | 45 | GraphQlRequest request = new DefaultExecutionGraphQlRequest( 46 | document, "HeroNameAndFriends", variables, extensions, "1", null); 47 | 48 | assertThat(request.toMap()) 49 | .containsEntry("query", document) 50 | .containsEntry("operationName", "HeroNameAndFriends") 51 | .containsEntry("variables", variables) 52 | .containsEntry("extensions", extensions); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /spring-graphql/src/test/resources/books/book-document.graphql: -------------------------------------------------------------------------------- 1 | bookById(id:"1") { 2 | id 3 | name 4 | } -------------------------------------------------------------------------------- /spring-graphql/src/test/resources/books/federation-schema.graphqls: -------------------------------------------------------------------------------- 1 | extend schema @link(url: "https://specs.apollo.dev/federation/v2.9", import: ["@key", "@extends", "@external"] ) 2 | 3 | type Book @key(fields: "id") @extends { 4 | id: ID! @external 5 | author: Author 6 | publisher: Publisher 7 | } 8 | 9 | type Author { 10 | id: ID 11 | firstName: String 12 | lastName: String 13 | } 14 | 15 | type Publisher @key(fields: "id", resolvable: false) { 16 | id: ID! @external 17 | } 18 | -------------------------------------------------------------------------------- /spring-graphql/src/test/resources/books/pagination-schema.graphqls: -------------------------------------------------------------------------------- 1 | type Query { 2 | books(first:Int, after:String): BookConnection 3 | } 4 | 5 | type Book { 6 | id: ID 7 | name: String 8 | } 9 | -------------------------------------------------------------------------------- /spring-graphql/src/test/resources/books/schema.graphqls: -------------------------------------------------------------------------------- 1 | type Query { 2 | bookById(id: ID): Book 3 | booksById(id: [ID]): [Book] 4 | books(id: ID, name: String, author: String): [Book!]! 5 | booksByNestedCriteria(id: ID, name: String, author: AuthorCriteria): [Book!]! 6 | booksByCriteria(criteria:BookCriteria): [Book] 7 | booksByProjectedArguments(name: String, author: String): [Book] 8 | booksByProjectedCriteria(criteria:BookCriteria): [Book] 9 | authorById(id: ID): Author 10 | } 11 | 12 | type Mutation { 13 | addAuthor(firstName: String, lastName: String): Author 14 | } 15 | 16 | type Subscription { 17 | bookSearch(author: String) : Book! 18 | } 19 | 20 | input BookCriteria { 21 | id: ID 22 | author: String 23 | } 24 | 25 | input AuthorCriteria { 26 | id: ID 27 | firstName: String 28 | lastName: String 29 | } 30 | 31 | type Book { 32 | id: ID 33 | name: String 34 | author: Author 35 | } 36 | 37 | type Author { 38 | id: ID 39 | firstName: String 40 | lastName: String 41 | } 42 | -------------------------------------------------------------------------------- /spring-graphql/src/test/resources/graphql-documents/greeting.graphql: -------------------------------------------------------------------------------- 1 | { greeting } -------------------------------------------------------------------------------- /spring-graphql/src/test/resources/log4j2-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /spring-graphql/src/testFixtures/java/org/springframework/graphql/GraphQlServiceSetup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql; 18 | 19 | import org.springframework.graphql.execution.DataLoaderRegistrar; 20 | import org.springframework.graphql.server.WebGraphQlHandler; 21 | import org.springframework.graphql.server.WebGraphQlSetup; 22 | 23 | /** 24 | * Workflow that results in the creation of a {@link ExecutionGraphQlService} or a 25 | * {@link WebGraphQlHandler}. 26 | * 27 | * @author Rossen Stoyanchev 28 | */ 29 | public interface GraphQlServiceSetup extends WebGraphQlSetup { 30 | 31 | GraphQlServiceSetup dataLoaders(DataLoaderRegistrar... registrars); 32 | 33 | TestExecutionGraphQlService toGraphQlService(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /spring-graphql/src/testFixtures/java/org/springframework/graphql/TestExecutionGraphQlService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql; 18 | 19 | import reactor.core.publisher.Mono; 20 | 21 | /** 22 | * Wrap an {@link ExecutionGraphQlService} to expose an addition convenience 23 | * method that takes a String document, and essentially hides the call to 24 | * {@link TestExecutionRequest#forDocument(String)}. 25 | * @author Rossen Stoyanchev 26 | */ 27 | public class TestExecutionGraphQlService implements ExecutionGraphQlService { 28 | 29 | private final ExecutionGraphQlService delegate; 30 | 31 | 32 | public TestExecutionGraphQlService(ExecutionGraphQlService delegate) { 33 | this.delegate = delegate; 34 | } 35 | 36 | 37 | public ExecutionGraphQlService getDelegate() { 38 | return this.delegate; 39 | } 40 | 41 | public Mono execute(String document) { 42 | ExecutionGraphQlRequest request = TestExecutionRequest.forDocument(document); 43 | return execute(request); 44 | } 45 | 46 | @Override 47 | public Mono execute(ExecutionGraphQlRequest request) { 48 | return this.delegate.execute(request); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /spring-graphql/src/testFixtures/java/org/springframework/graphql/TestExecutionRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql; 18 | 19 | import java.util.Collections; 20 | import java.util.Locale; 21 | import java.util.Map; 22 | import java.util.concurrent.atomic.AtomicLong; 23 | 24 | import org.springframework.graphql.support.DefaultExecutionGraphQlRequest; 25 | 26 | /** 27 | * {@link ExecutionGraphQlRequest} for use in tests with a convenient single-arg 28 | * constructor and simple incrementing id generation. 29 | * 30 | * @author Rossen Stoyanchev 31 | */ 32 | public final class TestExecutionRequest extends DefaultExecutionGraphQlRequest { 33 | 34 | private static final AtomicLong idIndex = new AtomicLong(); 35 | 36 | 37 | private TestExecutionRequest(String document, Map vars) { 38 | super(document, null, vars, null, String.valueOf(idIndex.incrementAndGet()), Locale.ENGLISH); 39 | } 40 | 41 | 42 | public static ExecutionGraphQlRequest forDocument(String document) { 43 | return new TestExecutionRequest(document, Collections.emptyMap()); 44 | } 45 | 46 | public static ExecutionGraphQlRequest forDocumentAndVars(String document, Map vars) { 47 | return new TestExecutionRequest(document, vars); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /spring-graphql/src/testFixtures/java/org/springframework/graphql/server/WebGraphQlSetup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.graphql.server; 18 | 19 | import org.springframework.graphql.server.webflux.GraphQlHttpHandler; 20 | 21 | /** 22 | * Workflow that results in the creation of a {@link WebGraphQlHandler} or 23 | * an HTTP handler for WebMvc or WebFlux. 24 | * 25 | * @author Rossen Stoyanchev 26 | */ 27 | public interface WebGraphQlSetup { 28 | 29 | WebGraphQlSetup interceptor(WebGraphQlInterceptor... interceptors); 30 | 31 | WebGraphQlHandler toWebGraphQlHandler(); 32 | 33 | org.springframework.graphql.server.webmvc.GraphQlHttpHandler toHttpHandler(); 34 | 35 | GraphQlHttpHandler toHttpHandlerWebFlux(); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/checkstyle/checkstyle-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/checkstyle/checkstyle.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/checkstyle/import-control.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | --------------------------------------------------------------------------------