├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── TODO.md ├── build.gradle ├── buildSrc └── src │ └── main │ └── groovy │ └── com │ └── graphql_java_generator │ └── gradle_task │ ├── ProcessesService.groovy │ ├── StartApp.groovy │ └── StopApp.groovy ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── graphql-gradle-plugin-docs ├── build.gradle └── src │ └── docs │ └── asciidoc │ └── graphqlPlugin.adoc ├── graphql-gradle-plugin-samples-CustomTemplates-resttemplate ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ └── main │ └── resources │ └── templates │ └── resttemplate │ ├── client_query_mutation_type.vm.java │ └── readme.md ├── graphql-gradle-plugin-samples-Forum-client ├── build.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── graphql_java_generator │ │ │ ├── minimal_app │ │ │ └── MinimalSpringApp.java │ │ │ ├── non_spring_app │ │ │ ├── NonSpringWithSpringGraphQLConfMain.java │ │ │ └── OldMain.java │ │ │ └── samples │ │ │ └── forum │ │ │ ├── SpringConfig.java │ │ │ ├── SpringMain.java │ │ │ └── client │ │ │ ├── DirectQueriesWithFieldInputParameters.java │ │ │ ├── PreparedQueriesWithFieldInputParameters.java │ │ │ ├── Queries.java │ │ │ ├── graphql │ │ │ ├── GraphQLReactiveRepositoryPartialRequests.java │ │ │ ├── GraphQLRepositoryPartialRequests.java │ │ │ ├── PartialDirectRequests.java │ │ │ └── PartialPreparedRequests.java │ │ │ └── subscription │ │ │ ├── PostSubscriptionCallback.java │ │ │ └── SubscriptionRequests.java │ └── resources │ │ ├── application.properties │ │ ├── forum_GraphQLSchema.json │ │ └── logback.xml │ ├── site │ └── site.xml │ └── test │ ├── java │ └── com │ │ └── graphql_java_generator │ │ └── samples │ │ └── forum │ │ └── test │ │ ├── MavenTestHelper.java │ │ ├── SpringTestConfig.java │ │ ├── client │ │ ├── BatchLoaderIT.java │ │ ├── DirectQueriesWithFieldInputParametersIT.java │ │ ├── FullRequestWithFragmentIT.java │ │ ├── IntrospectionIT.java │ │ ├── PreparedQueriesWithFieldInputParametersIT.java │ │ ├── graphql │ │ │ ├── AbstractIT.java │ │ │ ├── GraphQLRepositoryPartialRequestsSpringIT.java │ │ │ ├── PartialDirectRequestsIT.java │ │ │ ├── PartialPreparedRequestsIT.java │ │ │ └── ReactiveGraphQLRepositoriestIT.java │ │ └── subscription │ │ │ ├── SubscriptionIT.java │ │ │ └── SubscriptionNewTestIT.java │ │ └── jsonSchema │ │ ├── JsonSchemaFilenameIT.java │ │ └── package-info.java │ └── resources │ └── logback-test.xml ├── graphql-gradle-plugin-samples-Forum-server ├── build.gradle └── src │ ├── main │ ├── graphql │ │ └── forum_personalization.json │ ├── java │ │ └── org │ │ │ └── forum │ │ │ └── server │ │ │ ├── jpa │ │ │ ├── BoardRepository.java │ │ │ ├── FindTopicRepository.java │ │ │ ├── FindTopicRepositoryImpl.java │ │ │ ├── MemberRepository.java │ │ │ ├── PostRepository.java │ │ │ └── TopicRepository.java │ │ │ ├── oauth2 │ │ │ ├── HelloWorld.java │ │ │ └── WebSecurityConfiguration.java │ │ │ └── specific_code │ │ │ ├── DataFetchersDelegateBoardImpl.java │ │ │ ├── DataFetchersDelegateMemberImpl.java │ │ │ ├── DataFetchersDelegateMutationImpl.java │ │ │ ├── DataFetchersDelegatePostImpl.java │ │ │ ├── DataFetchersDelegateQueryImpl.java │ │ │ ├── DataFetchersDelegateSubscriptionImpl.java │ │ │ ├── DataFetchersDelegateTopicImpl.java │ │ │ ├── GraphQlException.java │ │ │ ├── MyDataFetcherExceptionResolverAdapter.java │ │ │ ├── MySubscriptionExceptionResolverAdapter.java │ │ │ └── PostPublisher.java │ └── resources │ │ ├── application.properties │ │ ├── data.sql │ │ ├── data.xlsx │ │ ├── forum.graphqls │ │ ├── logback-local.xml │ │ ├── logback.xml │ │ ├── schema.sql │ │ └── static │ │ └── graphiql-over-ws.html │ └── site │ └── site.xml ├── graphql-gradle-plugin-samples-OAuth-authorization-server ├── build.gradle └── src │ └── main │ ├── java │ └── com │ │ └── graphql_java_generator │ │ └── oauth_authorization_server │ │ ├── AuthorizationServerConfig.java │ │ ├── AuthorizationServerMain.java │ │ ├── DefaultSecurityConfig.java │ │ ├── HelloWorldController.java │ │ ├── Jwks.java │ │ └── KeyGeneratorUtils.java │ └── resources │ ├── application.yml │ ├── logback-local.xml │ └── logback.xml ├── graphql-gradle-plugin-samples-allGraphQLCases-client ├── .gitignore ├── CustomTemplates-resttemplate │ ├── client_query_mutation_type.vm.java │ └── readme.md ├── build.gradle └── src │ ├── graphqls │ ├── allGraphQLCases │ │ ├── allGraphQLCases.graphqls │ │ └── allGraphQLCases_extends.graphqls │ ├── customtemplates │ │ ├── client_subscription_type.vm.java │ │ ├── custom_client_subscription_executor.vm.java │ │ └── readme.md │ ├── forum │ │ └── forum.graphqls │ └── schema_personalization │ │ └── schema_personalization.json │ ├── main │ ├── java │ │ ├── com │ │ │ └── generated │ │ │ │ └── graphql │ │ │ │ └── samples │ │ │ │ └── customscalar │ │ │ │ ├── CustomId.java │ │ │ │ ├── GraphQLScalarTypeCustomId.java │ │ │ │ └── GraphQLScalarTypeMyBoolean.java │ │ └── org │ │ │ └── allGraphQLCases │ │ │ ├── annotation │ │ │ ├── AllEnums1.java │ │ │ ├── AllEnums2.java │ │ │ ├── LocalAnnotation.java │ │ │ ├── MyAdditionalAnnotation.java │ │ │ └── MyReplacementAnnotation.java │ │ │ ├── demo │ │ │ ├── GraphQLScalarTypeElse.java │ │ │ ├── Main.java │ │ │ ├── PartialQueries.java │ │ │ ├── SpringConfig.java │ │ │ ├── impl │ │ │ │ ├── PartialDirectQueries.java │ │ │ │ ├── PartialPreparedQueries.java │ │ │ │ ├── PartialPreparedQueriesDeprecatedWay.java │ │ │ │ ├── PartialRequestGraphQLReactiveRepository.java │ │ │ │ └── PartialRequestGraphQLRepository.java │ │ │ └── subscription │ │ │ │ ├── ExecSubscription.java │ │ │ │ └── SubscriptionCallbackListInteger.java │ │ │ ├── graphqlrepository │ │ │ └── non_spring │ │ │ │ ├── App.java │ │ │ │ └── GraphQLRequests.java │ │ │ ├── interfaces │ │ │ ├── AllInputTypes1.java │ │ │ ├── AllInputTypes2.java │ │ │ ├── AllInterfaces1.java │ │ │ ├── AllInterfaces2.java │ │ │ ├── AllTypes1.java │ │ │ ├── AllTypes2.java │ │ │ ├── AllUnions1.java │ │ │ ├── AllUnions2.java │ │ │ ├── AnyCharacterInterface.java │ │ │ ├── CharacterInterface.java │ │ │ ├── DroidInputInterface.java │ │ │ ├── HumanInterface.java │ │ │ └── package-info.java │ │ │ └── minimal │ │ │ ├── oauth_app │ │ │ ├── MinimalOAuthApp.java │ │ │ └── package-info.java │ │ │ └── spring_app │ │ │ ├── GraphQLRequests.java │ │ │ ├── MinimalSpringApp.java │ │ │ ├── SpringConfiguration.java │ │ │ └── package-info.java │ └── resources │ │ ├── application.properties │ │ └── logback.xml │ ├── site │ └── site.xml │ └── test │ ├── java │ ├── com │ │ └── graphql_java_generator │ │ │ ├── annotation │ │ │ └── GraphQLDirectiveTest.java │ │ │ ├── samples │ │ │ └── forum │ │ │ │ └── test │ │ │ │ └── client │ │ │ │ └── subscription │ │ │ │ ├── PostSubscriptionCallback.java │ │ │ │ └── SubscriptionIT.java │ │ │ └── schema_personalization │ │ │ └── CheckSchemaPersonalizationTest.java │ └── org │ │ ├── allGraphQLCases │ │ ├── AliasesIT.java │ │ ├── DirectiveOnFieldIT.java │ │ ├── EnumIT.java │ │ ├── ErrorIT.java │ │ ├── FragmentIT.java │ │ ├── FullQueriesDeprecatedIT.java │ │ ├── FullQueriesIT.java │ │ ├── GraphQLTransportWSIT.java │ │ ├── GraphQLTypeMappingTest.java │ │ ├── GraphQLVariablesIT.java │ │ ├── IntrospectionIT.java │ │ ├── JsonAndObjectIT.java │ │ ├── PartialQueryIT.java │ │ ├── PojoThatImplementsInterfaceIT.java │ │ ├── ReactiveQueriesIT.java │ │ ├── SpringTestConfig.java │ │ ├── UnionIT.java │ │ ├── graphqlrepositories │ │ │ ├── GraphQLReactiveRepositoryFullRequests.java │ │ │ └── GraphQLRepositoryFullRequests.java │ │ ├── impl │ │ │ ├── AbstractIT.java │ │ │ ├── OverriddenControllerIT.java │ │ │ ├── PartialDirectQueriesIT.java │ │ │ ├── PartialPreparedQueriesDeprecatedWayIT.java │ │ │ ├── PartialPreparedQueriesIT.java │ │ │ ├── PartialRequestGraphQLReactiveRepositoryIT.java │ │ │ └── PartialRequestGraphQLRepositoryIT.java │ │ ├── oauth │ │ │ ├── CheckOAuthIT.java │ │ │ └── SpringTestConfigWithoutOAuth.java │ │ ├── subscription │ │ │ ├── ExecSubscriptionIT.java │ │ │ ├── ExecSubscriptionWithGraphQLVariablesIT.java │ │ │ ├── SubscribeToADate.java │ │ │ ├── SubscriptionCallbackGeneric.java │ │ │ └── graphqlrepository │ │ │ │ ├── GraphQLRepositorySubscriptionIT.java │ │ │ │ ├── ReactiveGraphQLRepositorySubscriptionIT.java │ │ │ │ ├── SubscriptionGraphQLReactiveRepository.java │ │ │ │ ├── SubscriptionGraphQLRepository.java │ │ │ │ └── package-info.java │ │ └── two_graphql_servers │ │ │ ├── GraphQLRepoAllGraphQLCases.java │ │ │ ├── GraphQLRepoForum.java │ │ │ ├── RequestsAgainstTwoGraphQLServersIT.java │ │ │ └── package-info.java │ │ └── forum │ │ └── customtemplates │ │ └── ValidateCustomQueryIT.java │ └── resources │ ├── junit-platform.properties │ └── logback-test.xml ├── graphql-gradle-plugin-samples-allGraphQLCases-pojo-client-jackson ├── build.gradle └── src │ ├── main │ └── java │ │ └── com │ │ ├── generated │ │ └── graphql │ │ │ └── samples │ │ │ └── customscalar │ │ │ ├── CustomId.java │ │ │ ├── GraphQLScalarTypeCustomId.java │ │ │ └── GraphQLScalarTypeMyBoolean.java │ │ └── graphql_java_generator │ │ └── customscalars │ │ ├── GraphQLScalarTypeBase64String.java │ │ └── GraphQLScalarTypeDate.java │ └── test │ └── java │ └── org │ └── allGraphQLCases │ └── client │ └── pojo │ └── PojoTest.java ├── graphql-gradle-plugin-samples-allGraphQLCases-pojo-client ├── .gitignore ├── build.gradle └── src │ ├── main │ └── java │ │ └── com │ │ └── generated │ │ └── graphql │ │ └── samples │ │ └── customscalar │ │ ├── CustomId.java │ │ ├── GraphQLScalarTypeCustomId.java │ │ └── GraphQLScalarTypeMyBoolean.java │ └── test │ └── java │ └── org │ └── forum │ └── pojo │ └── PojoTest.java ├── graphql-gradle-plugin-samples-allGraphQLCases-pojo-server ├── .gitignore ├── build.gradle └── src │ ├── main │ └── java │ │ └── com │ │ └── generated │ │ └── graphql │ │ └── samples │ │ └── customscalar │ │ ├── CustomId.java │ │ ├── GraphQLScalarTypeCustomId.java │ │ └── GraphQLScalarTypeMyBoolean.java │ └── test │ └── java │ └── org │ └── forum │ └── pojo │ └── PojoTest.java ├── graphql-gradle-plugin-samples-allGraphQLCases-server ├── build.gradle └── src │ ├── main │ ├── graphql │ │ └── schema_personalization.json │ ├── java │ │ ├── com │ │ │ └── generated │ │ │ │ └── graphql │ │ │ │ └── samples │ │ │ │ └── customscalar │ │ │ │ ├── CustomId.java │ │ │ │ ├── GraphQLScalarTypeCustomId.java │ │ │ │ └── GraphQLScalarTypeMyBoolean.java │ │ └── org │ │ │ └── allGraphQLCases │ │ │ ├── annotation │ │ │ ├── AllEnums1.java │ │ │ ├── AllEnums2.java │ │ │ ├── LocalAnnotation.java │ │ │ ├── MyAdditionalAnnotation.java │ │ │ └── MyReplacementAnnotation.java │ │ │ ├── interfaces │ │ │ ├── AllInputTypes1.java │ │ │ ├── AllInputTypes2.java │ │ │ ├── AllInterfaces1.java │ │ │ ├── AllInterfaces2.java │ │ │ ├── AllTypes1.java │ │ │ ├── AllTypes2.java │ │ │ ├── AllUnions1.java │ │ │ ├── AllUnions2.java │ │ │ ├── AnyCharacterInterface.java │ │ │ ├── CharacterInterface.java │ │ │ ├── DroidInputInterface.java │ │ │ ├── HumanInterface.java │ │ │ └── package-info.java │ │ │ └── server │ │ │ ├── config │ │ │ ├── CustomBeans.java │ │ │ ├── GraphQlException.java │ │ │ ├── MyDataFetcherExceptionResolverAdapter.java │ │ │ ├── MyInstrumentation.java │ │ │ └── MySubscriptionExceptionResolverAdapter.java │ │ │ ├── impl │ │ │ ├── CharacterControllerOverridden.java │ │ │ ├── DataFetchersDelegateAllFieldCasesImpl.java │ │ │ ├── DataFetchersDelegateAllFieldCasesInterfaceImpl.java │ │ │ ├── DataFetchersDelegateAllFieldCasesInterfaceTypeImpl.java │ │ │ ├── DataFetchersDelegateAllFieldCasesWithIdSubtypeImpl.java │ │ │ ├── DataFetchersDelegateAnotherMutationTypeImpl.java │ │ │ ├── DataFetchersDelegateBatchMappingTypeImpl.java │ │ │ ├── DataFetchersDelegateCharacterImpl.java │ │ │ ├── DataFetchersDelegateCommentedImpl.java │ │ │ ├── DataFetchersDelegateDroidImpl.java │ │ │ ├── DataFetchersDelegateFoo140Impl.java │ │ │ ├── DataFetchersDelegateHumanImpl.java │ │ │ ├── DataFetchersDelegateI2Foo140Impl.java │ │ │ ├── DataFetchersDelegateIBar12Impl.java │ │ │ ├── DataFetchersDelegateIBar1Impl.java │ │ │ ├── DataFetchersDelegateIBar2Impl.java │ │ │ ├── DataFetchersDelegateIBar3Impl.java │ │ │ ├── DataFetchersDelegateIFoo140Impl.java │ │ │ ├── DataFetchersDelegateIFoo1Impl.java │ │ │ ├── DataFetchersDelegateIFoo2Impl.java │ │ │ ├── DataFetchersDelegateIFoo3Impl.java │ │ │ ├── DataFetchersDelegateIListImpl.java │ │ │ ├── DataFetchersDelegateMyQueryTypeImpl.java │ │ │ ├── DataFetchersDelegateNodeImpl.java │ │ │ ├── DataFetchersDelegatePetImpl.java │ │ │ ├── DataFetchersDelegateReservedJavaKeywordAllFieldCasesImpl.java │ │ │ ├── DataFetchersDelegateReservedJavaKeywordAsObjectField.java │ │ │ ├── DataFetchersDelegateReservedJavaKeywordAsObjectFieldImpl.java │ │ │ ├── DataFetchersDelegateTBar12Impl.java │ │ │ ├── DataFetchersDelegateTBar1Impl.java │ │ │ ├── DataFetchersDelegateTBar2Impl.java │ │ │ ├── DataFetchersDelegateTFoo12Impl.java │ │ │ ├── DataFetchersDelegateTFoo1Impl.java │ │ │ ├── DataFetchersDelegateTFoo3Impl.java │ │ │ ├── DataFetchersDelegateTListImpl.java │ │ │ ├── DataFetchersDelegateTheSubscriptionTypeImpl.java │ │ │ ├── DataFetchersDelegateTypeWithJsonImpl.java │ │ │ ├── DataFetchersDelegateTypeWithObjectImpl.java │ │ │ ├── DataFetchersDelegateWithIDImpl.java │ │ │ ├── DataFetchersDelegatebreakImpl.java │ │ │ ├── DataGenerator.java │ │ │ ├── GraphQLScalarTypeElse.java │ │ │ ├── MyQueryTypeControllerOverrided.java │ │ │ └── relayConnection │ │ │ │ ├── DataFetchersDelegateCharacterConnectionImpl.java │ │ │ │ ├── DataFetchersDelegateCharacterEdgeImpl.java │ │ │ │ ├── DataFetchersDelegateHumanConnectionImpl.java │ │ │ │ ├── DataFetchersDelegateHumanEdgeImpl.java │ │ │ │ └── package-info.java │ │ │ └── oauth2 │ │ │ ├── HelloWorld.java │ │ │ └── WebSecurityConfiguration.java │ └── resources │ │ ├── application.yml │ │ ├── logback-local.xml │ │ └── logback.xml │ ├── site │ └── site.xml │ └── test │ └── java │ └── com │ └── graphql_java_generator │ ├── annotation │ └── GraphQLDirectiveTest.java │ ├── plugin │ └── generate_code │ │ └── GenerateCodeDocumentParserTest.java │ └── schema_personalization │ └── CheckSchemaPersonalizationTest.java ├── graphql-gradle-plugin ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── graphql_java_generator │ │ │ └── gradleplugin │ │ │ ├── CommonExtension.java │ │ │ ├── CommonTask.java │ │ │ ├── GenerateClientCodeExtension.java │ │ │ ├── GenerateClientCodeSpringConfiguration.java │ │ │ ├── GenerateClientCodeTask.java │ │ │ ├── GenerateCodeCommonExtension.java │ │ │ ├── GenerateCodeCommonTask.java │ │ │ ├── GenerateGraphQLSchemaExtension.java │ │ │ ├── GenerateGraphQLSchemaSpringConfiguration.java │ │ │ ├── GenerateGraphQLSchemaTask.java │ │ │ ├── GeneratePojoExtension.java │ │ │ ├── GeneratePojoSpringConfiguration.java │ │ │ ├── GeneratePojoTask.java │ │ │ ├── GenerateServerCodeExtension.java │ │ │ ├── GenerateServerCodeSpringConfiguration.java │ │ │ ├── GenerateServerCodeTask.java │ │ │ ├── GraphQLExtension.java │ │ │ ├── GraphQLGenerateCodeSpringConfiguration.java │ │ │ ├── GraphQLGenerateCodeTask.java │ │ │ └── GraphQLPlugin.java │ └── resources │ │ └── application.properties │ └── test │ ├── java │ └── com │ │ └── graphql_java_generator │ │ └── gradleplugin │ │ ├── CommonTaskTest.java │ │ ├── FunctionalTest.java │ │ ├── GenerateClientCodeTaskTest.java │ │ ├── GenerateCodeCommonTaskTest.java │ │ ├── GenerateGraphQLSchemaTaskTest.java │ │ ├── GenerateServerCodeTaskTest.java │ │ ├── GraphQLGenerateCodeTaskTest.java │ │ └── GraphQLPluginTest.java │ └── resources │ ├── functionalTest │ ├── basic.graphqls │ ├── build_generateServerCode.gradle │ ├── build_registerTask.gradle │ ├── build_usingExtension.gradle │ └── settings.gradle │ └── log4j2-test.xml ├── graphql-gradle-plugin3 ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── graphql_java_generator │ │ │ └── gradleplugin │ │ │ ├── CommonExtension.java │ │ │ ├── CommonTask.java │ │ │ ├── GenerateClientCodeExtension.java │ │ │ ├── GenerateClientCodeSpringConfiguration.java │ │ │ ├── GenerateClientCodeTask.java │ │ │ ├── GenerateCodeCommonExtension.java │ │ │ ├── GenerateCodeCommonTask.java │ │ │ ├── GenerateGraphQLSchemaExtension.java │ │ │ ├── GenerateGraphQLSchemaSpringConfiguration.java │ │ │ ├── GenerateGraphQLSchemaTask.java │ │ │ ├── GeneratePojoExtension.java │ │ │ ├── GeneratePojoSpringConfiguration.java │ │ │ ├── GeneratePojoTask.java │ │ │ ├── GenerateServerCodeExtension.java │ │ │ ├── GenerateServerCodeSpringConfiguration.java │ │ │ ├── GenerateServerCodeTask.java │ │ │ ├── GraphQLExtension.java │ │ │ ├── GraphQLGenerateCodeSpringConfiguration.java │ │ │ ├── GraphQLGenerateCodeTask.java │ │ │ └── GraphQLPlugin.java │ └── resources │ │ └── application.properties │ └── test │ ├── java │ └── com │ │ └── graphql_java_generator │ │ └── gradleplugin │ │ ├── CommonTaskTest.java │ │ ├── FunctionalTest.java │ │ ├── GenerateClientCodeTaskTest.java │ │ ├── GenerateCodeCommonTaskTest.java │ │ ├── GenerateGraphQLSchemaTaskTest.java │ │ ├── GenerateServerCodeTaskTest.java │ │ ├── GraphQLGenerateCodeTaskTest.java │ │ └── GraphQLPluginTest.java │ └── resources │ ├── functionalTest │ ├── basic.graphqls │ ├── build.gradle │ ├── build_generateServerCode.gradle │ ├── build_registerTask.gradle │ ├── build_usingExtension.gradle │ └── settings.gradle │ └── log4j2-test.xml ├── graphql-java-generator (eclipse code formatter).xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build/ 6 | userHome/ 7 | 8 | # Ignore jvm dump files 9 | /*.hprof 10 | 11 | # Some files (including unit test log) coming from the maven part are still generated in target/ folders 12 | target 13 | 14 | # Ignore logs folder (generated during integration tests) 15 | logs/ 16 | **.log 17 | 18 | # Ignore eclipse files 19 | .settings/ 20 | .classpath 21 | .project 22 | bin/ 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 graphql-java-generator 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | # List of tasks that should be done 2 | * correct the #21 issue : spring 6.x dependencies must be added as compile dependencies. 3 | * Enhance dependency management (so that it's no more needed to provide two times the version number) 4 | -------------------------------------------------------------------------------- /buildSrc/src/main/groovy/com/graphql_java_generator/gradle_task/ProcessesService.groovy: -------------------------------------------------------------------------------- 1 | package com.graphql_java_generator.gradle_task 2 | 3 | import java.util.concurrent.ConcurrentHashMap 4 | 5 | import org.gradle.api.services.BuildService 6 | import org.gradle.api.services.BuildServiceParameters 7 | import org.gradle.api.tasks.Input 8 | import org.gradle.api.tasks.Internal 9 | import org.gradle.api.tasks.InputFile 10 | import org.gradle.api.tasks.TaskAction 11 | 12 | /** 13 | * This Gradle build service allows to store the process created by the StartApp task, so that the StopApp can stop it. Using 14 | * build service is mandatory when using Gradle configuration cache. Otherwise, it's easier to store that StartApp task in the StopApp task. 15 | */ 16 | abstract class ProcessesService implements BuildService { 17 | 18 | /** 19 | * The processes map for all the processes created by StartApp tasks: 20 | * - Key: the StartApp task path 21 | * - Process: the process started by this StartApp task 22 | */ 23 | @Internal 24 | Map processes; 25 | 26 | def ProcessesService() { 27 | processes = new ConcurrentHashMap<>() 28 | } 29 | 30 | def putProcess(String name, Process process) { 31 | processes.put(name, process) 32 | } 33 | 34 | def getProcess(String path) { 35 | return processes.get(path) 36 | } 37 | } -------------------------------------------------------------------------------- /buildSrc/src/main/groovy/com/graphql_java_generator/gradle_task/StopApp.groovy: -------------------------------------------------------------------------------- 1 | package com.graphql_java_generator.gradle_task 2 | 3 | import org.gradle.api.DefaultTask 4 | import org.gradle.api.provider.Property 5 | import org.gradle.api.services.ServiceReference 6 | import org.gradle.api.tasks.Input 7 | import org.gradle.api.tasks.TaskAction 8 | 9 | /** 10 | * The class below is largely inspired from Peter Ledbrook's answer in this stackoverflow thread: 11 | * https://stackoverflow.com/questions/31407323/running-integration-tests-for-a-spring-boot-rest-service-using-gradle 12 | */ 13 | public abstract class StopApp extends DefaultTask { 14 | 15 | /** The Gradle build service that contains the reference for all processes created by StartApp tasks */ 16 | @ServiceReference("startApp") 17 | abstract Property getProcessesServices() 18 | 19 | @Input 20 | String startAppTaskPath 21 | 22 | @TaskAction 23 | def stopApp(){ 24 | getProcessesServices().get().getProcess(startAppTaskPath).destroy() 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | group = 'com.graphql-java-generator' 2 | version = 2.9 3 | 4 | // The daemon needs more memory than the default one 5 | org.gradle.jvmargs = -Xmx1024m 6 | 7 | // This configuration block declares local project variable, with all versions for common dependencies 8 | commonsLang3Version = 3.12.0 9 | dozerVersion = 6.5.2 10 | graphqlJavaExtendedScalarsVersion = 20.0 11 | jaxbImplVersion = 2.3.1 12 | oauth2AuthorizationServerVersion = 0.3.1 13 | saajImplVersion = 1.5.1 14 | springBootVersion = 2.7.18 15 | springDependencyManagementPluginVersion = 1.0.15.RELEASE 16 | 17 | // The following properties are used by the forum samples (client and server) that use (and check) Spring Boot 3 support 18 | spring3_springBootVersion = 3.4.3 19 | spring3_DependencyManagementPluginVersion = 1.1.7 20 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphql-java-generator/graphql-gradle-plugin-project/a6fe37c08ae032c52784d38b4a121050b71f7041/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.6-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-docs/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.asciidoctor.convert' 3 | } 4 | 5 | asciidoctor { 6 | sources { 7 | include 'graphqlPlugin.adoc' 8 | } 9 | } 10 | 11 | build.dependsOn 'asciidoctor' -------------------------------------------------------------------------------- /graphql-gradle-plugin-docs/src/docs/asciidoc/graphqlPlugin.adoc: -------------------------------------------------------------------------------- 1 | = Greeter Command-line Application 2 | 3 | A simple application demonstrating the flexibility of a Gradle multi-project. 4 | 5 | == Installation 6 | 7 | Unpack the ZIP or TAR file in a suitable location 8 | 9 | == Usage 10 | 11 | [listing] 12 | ---- 13 | $ cd greeter-1.0 14 | $ ./bin/greeter gradlephant 15 | 16 | Hello, Gradlephant 17 | ---- -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-CustomTemplates-resttemplate/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | 3 | plugins { 4 | id 'java-library' 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-CustomTemplates-resttemplate/gradle.properties: -------------------------------------------------------------------------------- 1 | group = com.graphql-java-generator 2 | version = 2.1 3 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-CustomTemplates-resttemplate/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphql-java-generator/graphql-gradle-plugin-project/a6fe37c08ae032c52784d38b4a121050b71f7041/graphql-gradle-plugin-samples-CustomTemplates-resttemplate/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-CustomTemplates-resttemplate/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-CustomTemplates-resttemplate/gradlew: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphql-java-generator/graphql-gradle-plugin-project/a6fe37c08ae032c52784d38b4a121050b71f7041/graphql-gradle-plugin-samples-CustomTemplates-resttemplate/gradlew -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-CustomTemplates-resttemplate/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'graphql-gradle-plugin-samples-CustomTemplates-resttemplate' -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-CustomTemplates-resttemplate/src/main/resources/templates/resttemplate/readme.md: -------------------------------------------------------------------------------- 1 | # Explanation 2 | 3 | This template is a copy/paste of the 'client_query_mutation_type.vm.java' template, with this only modification: 4 | * Add of a boolean field: thisIsADummyFieldToCheckThatThisTemplateIsUsed. It is checked in the IT test, to check that the custom templates is actually used. 5 | 6 | 7 | # Internal note 8 | 9 | # To update it : 10 | 11 | * Copy/paste the `client_query_mutation_type.vm.java` template, from the plugin-logic module. 12 | * Add the thisIsADummyFieldToCheckThatThisTemplateIsUsed just after the class declaration, like this : 13 | 14 | ```Java 15 | ${object.annotation} 16 | @SuppressWarnings("unused") 17 | public class ${object.classSimpleName} extends ${object.name}Executor${springBeanSuffix} #if(!${configuration.separateUtilityClasses} && ${object.requestType})implements com.graphql_java_generator.client.GraphQLRequestObject #end{ 18 | 19 | /** 20 | * The field below is the only change from the original template. It is here only to check that 21 | * this template is actually used 22 | */ 23 | public boolean thisIsADummyFieldToCheckThatThisTemplateIsUsed = true; 24 | 25 | 26 | ``` 27 | 28 | ## To document it 29 | 30 | A good idea is to add these lines at the beginning of the file, for documentation: 31 | 32 | ```md 33 | ## 34 | ## This template is a copy/paste of the 'client_query_mutation_type.vm.java' template, with this only modification: 35 | ## - Add of a boolean field: thisIsADummyFieldToCheckThatThisTemplateIsUsed. It is checked in the IT test, 36 | ## to check that the custom templates is actually used. 37 | ## 38 | ``` 39 | 40 | ## To test it 41 | 42 | The `com.graphql_java_generator.samples.basic.client.ValidateCustomQueryIT` integration test checks that the thisIsADummyFieldToCheckThatThisTemplateIsUsed is true, which implies that the field exists, and so that the custom templates has been used to generate the code. -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-client/src/main/java/com/graphql_java_generator/non_spring_app/OldMain.java: -------------------------------------------------------------------------------- 1 | package com.graphql_java_generator.non_spring_app; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * This class is the old Main class, that is the Main class for the non-spring app that we want to execute with the 7 | * plugin. 8 | * 9 | * @author etienne-sf 10 | * 11 | */ 12 | public class OldMain { 13 | 14 | public static void main(String[] args) throws Exception { 15 | // A basic demo of input parameters 16 | @SuppressWarnings("deprecation") 17 | Date date = new Date(2019 - 1900, 12 - 1, 20); 18 | 19 | // For this simple sample, we execute a direct query. But prepared queries are recommended. 20 | // Please note that input parameters are mandatory for list or input types. 21 | System.out.println( 22 | "Executing query: '{id name publiclyAvailable topics(since: ¶m){id}}', with input parameter param of value '" 23 | + date + "'"); 24 | 25 | // In the below line, NonSpringWithSpringGraphQLConfApp static getter is used to retrieve the QueryExecutor 26 | System.out.println(NonSpringWithSpringGraphQLConfMain.getQueryExecutor() 27 | .boards("{id name publiclyAvailable topics(since: ¶m){id}}", "param", date)); 28 | 29 | System.out.println("Normal end of the application"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-client/src/main/java/com/graphql_java_generator/samples/forum/client/PreparedQueriesWithFieldInputParameters.java: -------------------------------------------------------------------------------- 1 | package com.graphql_java_generator.samples.forum.client; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Component; 8 | 9 | import com.graphql_java_generator.exception.GraphQLRequestExecutionException; 10 | import com.graphql_java_generator.exception.GraphQLRequestPreparationException; 11 | import com.graphql_java_generator.samples.forum.client.graphql.forum.client.Topic; 12 | import com.graphql_java_generator.samples.forum.client.graphql.forum.client.util.GraphQLRequest; 13 | import com.graphql_java_generator.samples.forum.client.graphql.forum.client.util.QueryExecutor; 14 | 15 | import jakarta.annotation.PostConstruct; 16 | 17 | /** 18 | * Check that the server correctly works with the combination for the arguments for the post field: as there are 19 | * optional argument, multiple queries must be implemented. In order to the sample to be properly coded, all must be 20 | * tested. 21 | * 22 | * @author etienne-sf 23 | * 24 | */ 25 | @Component 26 | public class PreparedQueriesWithFieldInputParameters { 27 | 28 | @Autowired 29 | QueryExecutor queryType; 30 | GraphQLRequest topicAuthorPostAuthorResponse; 31 | 32 | @PostConstruct 33 | public void postConstruct() throws GraphQLRequestPreparationException { 34 | topicAuthorPostAuthorResponse = queryType.getTopicsGraphQLRequest( 35 | "{id date author{name email alias id type} nbPosts title content posts(memberId:?memberId, memberName:?memberName, since:?since){id date author{name email alias} title content}}"); 36 | } 37 | 38 | /** 39 | * Execute the query, with the given parameters. Optional parameters may be null. 40 | * 41 | * @return 42 | * 43 | * @throws GraphQLRequestExecutionException 44 | */ 45 | public List boardsWithPostSince(String boardName, String memberId, String memberName, Date since) 46 | throws GraphQLRequestExecutionException { 47 | return queryType.topics(topicAuthorPostAuthorResponse, boardName, "memberId", memberId, "memberName", 48 | memberName, "since", since); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-client/src/main/java/com/graphql_java_generator/samples/forum/client/subscription/PostSubscriptionCallback.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.graphql_java_generator.samples.forum.client.subscription; 5 | 6 | import java.util.concurrent.CountDownLatch; 7 | 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | import com.graphql_java_generator.client.SubscriptionCallback; 12 | import com.graphql_java_generator.samples.forum.client.graphql.forum.client.Post; 13 | 14 | /** 15 | * @author etienne-sf 16 | */ 17 | // The class that'll receive the notification from the GraphQL subscription 18 | 19 | public class PostSubscriptionCallback implements SubscriptionCallback { 20 | 21 | /** The logger for this class */ 22 | static protected Logger logger = LoggerFactory.getLogger(PostSubscriptionCallback.class); 23 | 24 | /** Indicates whether the Web Socket is connected or not */ 25 | public boolean connected = false; 26 | 27 | public int nbReceivedMessages = 0; 28 | public Post lastReceivedMessage = null; 29 | public String lastReceivedClose = null; 30 | public Throwable lastReceivedError = null; 31 | 32 | public CountDownLatch latchNewMessage = new CountDownLatch(1); 33 | 34 | @Override 35 | public void onConnect() { 36 | this.connected = true; 37 | logger.debug("The 'subscribeToNewPostWithBindValues' subscription is now active (the web socket is connected)"); 38 | } 39 | 40 | @Override 41 | public void onMessage(Post t) { 42 | logger.debug( 43 | "Received a notification from the 'subscribeToNewPostWithBindValues' subscription, for this post {} ", 44 | t); 45 | nbReceivedMessages += 1; 46 | lastReceivedMessage = t; 47 | latchNewMessage.countDown(); 48 | // Do something useful with it 49 | } 50 | 51 | @Override 52 | public void onClose(int statusCode, String reason) { 53 | connected = false; 54 | lastReceivedClose = statusCode + "-" + reason; 55 | logger.debug("Received onClose: {}", lastReceivedClose); 56 | } 57 | 58 | @Override 59 | public void onError(Throwable cause) { 60 | connected = false; 61 | lastReceivedError = cause; 62 | logger.debug("Received onError: {}", cause); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-client/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | graphql.endpoint.url = http://localhost:8182/graphql 3 | 4 | # We don't need the Netty web server to start (but its dependencies are mandatory) 5 | spring.main.web-application-type = none 6 | 7 | # Configuration for OAuth2, for our local OAuth authorization server 8 | spring.security.oauth2.client.registration.provider_test.authorization-grant-type=client_credentials 9 | spring.security.oauth2.client.registration.provider_test.client-id=clientId 10 | spring.security.oauth2.client.registration.provider_test.client-secret=secret 11 | # spring.security.oauth2.client.registration.provider_test.scope=ROLE_CLIENT 12 | 13 | # Definition of the token provider url 14 | spring.security.oauth2.client.provider.provider_test.token-uri=http://localhost:8181/oauth2/token 15 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-client/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 7 | 8 | 9 | 10 | target/client.log 11 | 12 | %date %level [%thread] %logger{10} [%file:%line] %msg%n 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-client/src/site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | org.apache.maven.skins 6 | maven-fluido-skin 7 | 2.0.0-M5 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-client/src/test/java/com/graphql_java_generator/samples/forum/test/client/graphql/GraphQLRepositoryPartialRequestsSpringIT.java: -------------------------------------------------------------------------------- 1 | package com.graphql_java_generator.samples.forum.test.client.graphql; 2 | 3 | import org.junit.jupiter.api.BeforeEach; 4 | import org.junit.jupiter.api.extension.ExtendWith; 5 | import org.junit.jupiter.api.parallel.Execution; 6 | import org.junit.jupiter.api.parallel.ExecutionMode; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.test.context.ContextConfiguration; 9 | import org.springframework.test.context.TestPropertySource; 10 | import org.springframework.test.context.junit.jupiter.SpringExtension; 11 | 12 | import com.graphql_java_generator.samples.forum.client.graphql.GraphQLRepositoryPartialRequests; 13 | import com.graphql_java_generator.samples.forum.test.SpringTestConfig; 14 | 15 | /** 16 | * Integration tests for GraphQL Repository, in Spring mode
17 | * As it is suffixed by "IT", this is an integration test. Thus, it allows us to start the GraphQL Forum server, see the 18 | * pom.xml file for details. 19 | * 20 | * @author etienne-sf 21 | */ 22 | @ExtendWith(SpringExtension.class) 23 | @ContextConfiguration(classes = { SpringTestConfig.class }) 24 | @TestPropertySource("classpath:application.properties") 25 | @Execution(ExecutionMode.CONCURRENT) 26 | class GraphQLRepositoryPartialRequestsSpringIT extends AbstractIT { 27 | 28 | @Autowired 29 | GraphQLRepositoryPartialRequests graphQLRepositoryPartialRequests; 30 | 31 | @BeforeEach 32 | void setUp() throws Exception { 33 | queries = graphQLRepositoryPartialRequests; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-client/src/test/java/com/graphql_java_generator/samples/forum/test/client/graphql/PartialDirectRequestsIT.java: -------------------------------------------------------------------------------- 1 | package com.graphql_java_generator.samples.forum.test.client.graphql; 2 | 3 | import org.junit.jupiter.api.BeforeEach; 4 | import org.junit.jupiter.api.extension.ExtendWith; 5 | import org.junit.jupiter.api.parallel.Execution; 6 | import org.junit.jupiter.api.parallel.ExecutionMode; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.test.context.ContextConfiguration; 9 | import org.springframework.test.context.TestPropertySource; 10 | import org.springframework.test.context.junit.jupiter.SpringExtension; 11 | 12 | import com.graphql_java_generator.samples.forum.client.graphql.PartialDirectRequests; 13 | import com.graphql_java_generator.samples.forum.test.SpringTestConfig; 14 | 15 | /** 16 | * As it is suffixed by "IT", this is an integration test. Thus, it allows us to start the GraphQL Forum server, see 17 | * the pom.xml file for details. 18 | * 19 | * @author etienne-sf 20 | */ 21 | @ExtendWith(SpringExtension.class) 22 | @ContextConfiguration(classes = { SpringTestConfig.class }) 23 | @TestPropertySource("classpath:application.properties") 24 | @Execution(ExecutionMode.CONCURRENT) 25 | class PartialDirectRequestsIT extends AbstractIT { 26 | 27 | @Autowired 28 | PartialDirectRequests partialDirectRequests; 29 | 30 | @BeforeEach 31 | void setUp() throws Exception { 32 | queries = partialDirectRequests; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-client/src/test/java/com/graphql_java_generator/samples/forum/test/client/graphql/PartialPreparedRequestsIT.java: -------------------------------------------------------------------------------- 1 | package com.graphql_java_generator.samples.forum.test.client.graphql; 2 | 3 | import org.junit.jupiter.api.BeforeEach; 4 | import org.junit.jupiter.api.extension.ExtendWith; 5 | import org.junit.jupiter.api.parallel.Execution; 6 | import org.junit.jupiter.api.parallel.ExecutionMode; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.test.context.ContextConfiguration; 9 | import org.springframework.test.context.TestPropertySource; 10 | import org.springframework.test.context.junit.jupiter.SpringExtension; 11 | 12 | import com.graphql_java_generator.samples.forum.client.graphql.PartialPreparedRequests; 13 | import com.graphql_java_generator.samples.forum.test.SpringTestConfig; 14 | 15 | /** 16 | * As it is suffixed by "IT", this is an integration test. Thus, it allows us to start the GraphQL Forum server, see 17 | * the pom.xml file for details. 18 | * 19 | * @author etienne-sf 20 | */ 21 | @ExtendWith(SpringExtension.class) 22 | @ContextConfiguration(classes = { SpringTestConfig.class }) 23 | @TestPropertySource("classpath:application.properties") 24 | @Execution(ExecutionMode.CONCURRENT) 25 | class PartialPreparedRequestsIT extends AbstractIT { 26 | 27 | @Autowired 28 | PartialPreparedRequests partialPreparedDirectRequests; 29 | 30 | @BeforeEach 31 | void setUp() throws Exception { 32 | queries = partialPreparedDirectRequests; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-client/src/test/java/com/graphql_java_generator/samples/forum/test/jsonSchema/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains tests for the jsonSchemaFilename parameter.
3 | * This parameter defines a json file that contains the result of an introspection query. 4 | */ 5 | package com.graphql_java_generator.samples.forum.test.jsonSchema; 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-client/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 7 | 8 | 9 | 10 | target/JUnit-tests.log 11 | 12 | %date %level [%thread] %logger{10} [%file:%line] %msg%n 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-server/src/main/graphql/forum_personalization.json: -------------------------------------------------------------------------------- 1 | { 2 | "entityPersonalizations": [ 3 | { 4 | "name": "Member", 5 | "fieldPersonalizations": [ 6 | { 7 | "name": "type", 8 | "addAnnotation": "@jakarta.persistence.Enumerated(jakarta.persistence.EnumType.STRING)" 9 | } 10 | ] }, 11 | { 12 | "name": "Post", 13 | "newFields": [ 14 | { 15 | "name": "authorId", 16 | "type": "ID", 17 | "id": false, 18 | "list": false, 19 | "mandatory": false 20 | }, 21 | { 22 | "name": "topicId", 23 | "type": "ID", 24 | "id": false, 25 | "list": false, 26 | "mandatory": false 27 | } 28 | ] 29 | }, 30 | { 31 | "name": "Topic", 32 | "newFields": [ 33 | { 34 | "name": "boardId", 35 | "type": "ID", 36 | "id": false, 37 | "list": false, 38 | "mandatory": false 39 | }, 40 | { 41 | "name": "authorId", 42 | "type": "ID", 43 | "id": false, 44 | "list": false, 45 | "mandatory": false 46 | } 47 | ] 48 | } 49 | ] 50 | } -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-server/src/main/java/org/forum/server/jpa/BoardRepository.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.forum.server.jpa; 5 | 6 | import java.util.List; 7 | 8 | import org.forum.server.graphql.Board; 9 | import org.springframework.data.jpa.repository.Query; 10 | import org.springframework.data.repository.CrudRepository; 11 | 12 | /** 13 | * 14 | * @author etienne-sf 15 | */ 16 | public interface BoardRepository extends CrudRepository { 17 | 18 | /** The query for the BatchLoader */ 19 | @Query(value = "select b from Board b where b.id in ?1") 20 | List findByIds(List ids); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-server/src/main/java/org/forum/server/jpa/FindTopicRepository.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.forum.server.jpa; 5 | 6 | import java.util.List; 7 | 8 | import org.forum.server.graphql.Topic; 9 | 10 | /** 11 | * @author etienne-sf 12 | */ 13 | public interface FindTopicRepository { 14 | 15 | /** 16 | * Search for {@link Topic}, based on 17 | * 18 | * @param boardName 19 | * @param keyword 20 | * @return 21 | */ 22 | List findByBoardNameAndKeywords(String boardName, List keyword); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-server/src/main/java/org/forum/server/jpa/FindTopicRepositoryImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.forum.server.jpa; 5 | 6 | import java.util.List; 7 | 8 | import org.forum.server.graphql.Topic; 9 | 10 | import jakarta.persistence.EntityManager; 11 | import jakarta.persistence.PersistenceContext; 12 | 13 | /** 14 | * @author etienne-sf 15 | */ 16 | public class FindTopicRepositoryImpl implements FindTopicRepository { 17 | 18 | @PersistenceContext 19 | private EntityManager em; 20 | 21 | /** 22 | * Search for {@link Topic}, based on 23 | * 24 | * @param boardName 25 | * @param keyword 26 | * @return 27 | */ 28 | @SuppressWarnings("unchecked") 29 | @Override 30 | public List findByBoardNameAndKeywords(String boardName, List keyword) { 31 | String query = ""// 32 | + " select t.* " // 33 | + " from Topic t "// 34 | + " join Board b on t.board_id = b.id "// 35 | + " where b.name = '" + boardName.replace("'", "''") + "'"; 36 | if (keyword != null) { 37 | for (String word : keyword) { 38 | String wordSQL = word.replace("'", "''"); // This should be secured and optimized for a real production 39 | // server 40 | query += " and ( t.title like '%" + wordSQL + "%' or t.content like '%" + wordSQL + "%')"; 41 | } 42 | } 43 | return em.createNativeQuery(query, Topic.class).getResultList(); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-server/src/main/java/org/forum/server/jpa/MemberRepository.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.forum.server.jpa; 5 | 6 | import java.util.List; 7 | 8 | import org.forum.server.graphql.Member; 9 | import org.springframework.data.jpa.repository.Query; 10 | import org.springframework.data.repository.CrudRepository; 11 | 12 | /** 13 | * @author etienne-sf 14 | */ 15 | public interface MemberRepository extends CrudRepository { 16 | 17 | /** The query for the BatchLoader */ 18 | @Query(value = "select m from Member m where id in ?1") 19 | List findByIds(List ids); 20 | } 21 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-server/src/main/java/org/forum/server/jpa/PostRepository.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.forum.server.jpa; 5 | 6 | import java.util.Date; 7 | import java.util.List; 8 | 9 | import org.forum.server.graphql.Post; 10 | import org.springframework.data.jpa.repository.Query; 11 | import org.springframework.data.repository.CrudRepository; 12 | 13 | /** 14 | * @author etienne-sf 15 | */ 16 | public interface PostRepository extends CrudRepository { 17 | 18 | @Query(value = "select p from Post p where p.topicId= ?1") 19 | List findByTopicId(Long topicId); 20 | 21 | @Query(value = "select p from Post p where p.topicId= ?1 and p.date >= ?2") 22 | List findByTopicIdAndSince(Long id, Date since); 23 | 24 | @Query(value = "select p from Post p where p.topicId= ?1 and p.authorId =?2 and p.date >= ?3") 25 | List findByTopicIdAndMemberIdAndSince(Long id, Long memberId, Date since); 26 | 27 | @Query(value = "" // 28 | + " select p "// 29 | + " from Post p "// 30 | + " join Member m on m.id=p.authorId" // 31 | + " where p.topicId= ?1 "// 32 | + " and m.name =?2 "// 33 | + " and p.date >= ?3") 34 | List findByTopicIdAndMemberNameAndSince(Long id, String memberName, Date since); 35 | 36 | // It's actually a non sense request, as if you provide author_id, it's useless to provide his/her name. But, as 37 | // it's a technical possibility, the query must be defined 38 | @Query(value = "" // 39 | + " select p "// 40 | + " from Post p "// 41 | + " join Member m on m.id=p.authorId" // 42 | + " where p.topicId= ?1 "// 43 | + " and p.authorId =?2 "// 44 | + " and m.name = ?3 "// 45 | + " and p.date >= ?4") 46 | List findByTopicIdAndMemberIdAndMemberNameAndSince(Long id, Long memberId, String memberName, Date since); 47 | 48 | /** The query for the BatchLoader */ 49 | @Query(value = "select p from Post p where id in ?1") 50 | List findByIds(List ids); 51 | } 52 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-server/src/main/java/org/forum/server/jpa/TopicRepository.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.forum.server.jpa; 5 | 6 | import java.util.Date; 7 | import java.util.List; 8 | 9 | import org.forum.server.graphql.Topic; 10 | import org.springframework.data.jpa.repository.Query; 11 | import org.springframework.data.repository.CrudRepository; 12 | 13 | /** 14 | * @author etienne-sf 15 | */ 16 | public interface TopicRepository extends CrudRepository, FindTopicRepository { 17 | 18 | @Query(value = "select t from Topic t where t.boardId= ?1") 19 | List findByBoardId(Long boardId); 20 | 21 | @Query(value = "select t from Topic t where t.boardId= ?1 and t.date >= ?2") 22 | List findByBoardIdAndSince(Long boardId, Date since); 23 | 24 | /** 25 | * An example of a native query that could be used for some particular case 26 | * 27 | * @param name 28 | * @return 29 | */ 30 | @Query(value = "" // 31 | + " select t.* " // 32 | + " from Topic t "// 33 | + " join Board b on t.board_id = b.id " // 34 | + " where b.name = ?1" // 35 | , nativeQuery = true) 36 | List findByBoardName(String name); 37 | 38 | /** The query for the BatchLoader */ 39 | @Query(value = "select t from Topic t where id in ?1") 40 | List findByIds(List ids); 41 | } 42 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-server/src/main/java/org/forum/server/oauth2/HelloWorld.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.forum.server.oauth2; 5 | 6 | import java.security.Principal; 7 | 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | /** 12 | * This URI is used in maven build, to check that the server is properly started. 13 | * 14 | * @author etienne-sf 15 | */ 16 | @RestController 17 | public class HelloWorld { 18 | 19 | @GetMapping("/helloworld.html") 20 | public String get(final Principal principal) { 21 | return "Hello World, I'm started!"; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-server/src/main/java/org/forum/server/oauth2/WebSecurityConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.forum.server.oauth2; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 6 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 7 | import org.springframework.security.web.SecurityFilterChain; 8 | 9 | /** 10 | * Spring Security configuration to configure OAuth2 only for the /graphql path, and to disable CSRF. 11 | * 12 | * @author etienne-sf 13 | */ 14 | @Configuration 15 | @EnableWebSecurity 16 | public class WebSecurityConfiguration { 17 | 18 | @Bean 19 | SecurityFilterChain filterChain(HttpSecurity http) throws Exception { 20 | http// 21 | // Disabling CORS and CSRF makes POST on the graphql URL work properly. Double-check that before 22 | // entering in production 23 | .cors().and().csrf().disable()// 24 | .authorizeHttpRequests(// 25 | authorize -> authorize// 26 | .requestMatchers("/graphql") /* .hasAuthority("ROLE_CLIENT") */ .authenticated()// 27 | .anyRequest().anonymous() 28 | // Other paths are not protected 29 | )// 30 | .oauth2ResourceServer().jwt(); 31 | return http.build(); 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-server/src/main/java/org/forum/server/specific_code/DataFetchersDelegateMemberImpl.java: -------------------------------------------------------------------------------- 1 | package org.forum.server.specific_code; 2 | 3 | import java.util.List; 4 | 5 | import org.dataloader.BatchLoaderEnvironment; 6 | import org.forum.server.graphql.Member; 7 | import org.forum.server.graphql.util.DataFetchersDelegateMember; 8 | import org.forum.server.jpa.MemberRepository; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.stereotype.Component; 12 | 13 | import jakarta.annotation.Resource; 14 | 15 | @Component 16 | public class DataFetchersDelegateMemberImpl implements DataFetchersDelegateMember { 17 | 18 | /** The logger for this instance */ 19 | protected Logger logger = LoggerFactory.getLogger(DataFetchersDelegateMemberImpl.class); 20 | 21 | @Resource 22 | MemberRepository memberRepository; 23 | 24 | @Override 25 | public List batchLoader(List keys, BatchLoaderEnvironment env) { 26 | logger.debug("Batch loading {} members", keys.size()); 27 | List ret = memberRepository.findByIds(keys); 28 | 29 | // Let's mark all the entries retrieved here by [BL] (Batch Loader), to check this in integration tests. 30 | // These tests are in the graphql-maven-plugin-samples-Forum-client project 31 | for (Member m : ret) { 32 | m.setName("[BL] " + m.getName()); 33 | } 34 | 35 | return ret; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-server/src/main/java/org/forum/server/specific_code/DataFetchersDelegateQueryImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.forum.server.specific_code; 5 | 6 | import java.util.List; 7 | 8 | import org.forum.server.graphql.Board; 9 | import org.forum.server.graphql.Topic; 10 | import org.forum.server.graphql.util.DataFetchersDelegateQuery; 11 | import org.forum.server.jpa.BoardRepository; 12 | import org.forum.server.jpa.TopicRepository; 13 | import org.springframework.stereotype.Component; 14 | 15 | import com.graphql_java_generator.util.GraphqlUtils; 16 | 17 | import graphql.schema.DataFetchingEnvironment; 18 | import jakarta.annotation.Resource; 19 | 20 | /** 21 | * @author etienne-sf 22 | */ 23 | @Component 24 | public class DataFetchersDelegateQueryImpl implements DataFetchersDelegateQuery { 25 | 26 | @Resource 27 | BoardRepository boardRepository; 28 | @Resource 29 | TopicRepository topicRepository; 30 | 31 | @Resource 32 | GraphqlUtils graphqlUtils; 33 | 34 | @Override 35 | public List boards(DataFetchingEnvironment dataFetchingEnvironment) { 36 | return graphqlUtils.iterableToList(boardRepository.findAll()); 37 | } 38 | 39 | @Override 40 | public Integer nbBoards(DataFetchingEnvironment dataFetchingEnvironment) { 41 | return (int) boardRepository.count(); 42 | } 43 | 44 | @Override 45 | public List topics(DataFetchingEnvironment dataFetchingEnvironment, String boardName) { 46 | return topicRepository.findByBoardName(boardName); 47 | } 48 | 49 | @Override 50 | public List findTopics(DataFetchingEnvironment dataFetchingEnvironment, String boardName, 51 | List keyword) { 52 | return topicRepository.findByBoardNameAndKeywords(boardName, keyword); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-server/src/main/java/org/forum/server/specific_code/DataFetchersDelegateSubscriptionImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.forum.server.specific_code; 5 | 6 | import org.forum.server.graphql.Post; 7 | import org.forum.server.graphql.util.DataFetchersDelegateSubscription; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.stereotype.Component; 11 | 12 | import graphql.schema.DataFetchingEnvironment; 13 | import jakarta.annotation.Resource; 14 | import reactor.core.publisher.Flux; 15 | 16 | /** 17 | * @author etienne-sf 18 | */ 19 | @Component 20 | public class DataFetchersDelegateSubscriptionImpl implements DataFetchersDelegateSubscription { 21 | 22 | /** The logger for this instance */ 23 | static Logger logger = LoggerFactory.getLogger(DataFetchersDelegateSubscriptionImpl.class); 24 | 25 | /** 26 | * This {@link PostPublisher} will be notified for each Post creation. This is the basis for the 27 | * subscribeToNewPost subscription 28 | */ 29 | @Resource 30 | PostPublisher postPublisher; 31 | 32 | @Override 33 | public Flux subscribeToNewPost(DataFetchingEnvironment dataFetchingEnvironment, String boardName) { 34 | logger.debug("Received a Subscription for {}", boardName); 35 | Flux publisher = postPublisher.getPublisher(boardName); 36 | logger.trace("The publisher has been acquired for the Subscription for {}", boardName); 37 | return publisher; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-server/src/main/java/org/forum/server/specific_code/GraphQlException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.forum.server.specific_code; 5 | 6 | import java.util.List; 7 | 8 | import org.springframework.graphql.execution.ErrorType; 9 | 10 | import graphql.ErrorClassification; 11 | import graphql.GraphQLError; 12 | import graphql.language.SourceLocation; 13 | 14 | /** 15 | * Instances of this classes will be sent back as INTERNAL_ERROR GraphQL errors, with their message 16 | * 17 | * @author etienne-sf 18 | */ 19 | public class GraphQlException extends RuntimeException implements GraphQLError { 20 | 21 | private static final long serialVersionUID = 1L; 22 | 23 | public GraphQlException(String msg) { 24 | super(msg); 25 | } 26 | 27 | @Override 28 | public List getLocations() { 29 | return null; 30 | } 31 | 32 | @Override 33 | public ErrorClassification getErrorType() { 34 | return ErrorType.INTERNAL_ERROR; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-server/src/main/java/org/forum/server/specific_code/MyDataFetcherExceptionResolverAdapter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.forum.server.specific_code; 5 | 6 | import org.springframework.graphql.execution.DataFetcherExceptionResolverAdapter; 7 | import org.springframework.stereotype.Component; 8 | 9 | import graphql.GraphQLError; 10 | import graphql.schema.DataFetchingEnvironment; 11 | 12 | /** 13 | * A Spring bean that register {@link DataFetcherExceptionResolverAdapter} to configure the way Java exceptions are 14 | * mapped to GraphQL errors.
15 | * This class is both a sample, and the support for an IT test that checks proper error management on client side, when 16 | * an error occurs on server side. 17 | * 18 | * @author etienne-sf 19 | */ 20 | @Component 21 | public class MyDataFetcherExceptionResolverAdapter extends DataFetcherExceptionResolverAdapter { 22 | 23 | @Override 24 | protected GraphQLError resolveToSingleError(Throwable ex, DataFetchingEnvironment env) { 25 | if (ex.getClass().equals(GraphQlException.class)) { 26 | return (GraphQLError) ex; 27 | } else { 28 | // Otherwise, it's not a know error. Let's stick to the default behavior 29 | return null; 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-server/src/main/java/org/forum/server/specific_code/MySubscriptionExceptionResolverAdapter.java: -------------------------------------------------------------------------------- 1 | package org.forum.server.specific_code; 2 | 3 | import org.springframework.graphql.execution.SubscriptionExceptionResolverAdapter; 4 | import org.springframework.stereotype.Component; 5 | 6 | import graphql.GraphQLError; 7 | 8 | /** 9 | * Implements the spring-graphql exception management, for Subscriptions 10 | * 11 | * @author etienne-sf 12 | */ 13 | @Component 14 | public class MySubscriptionExceptionResolverAdapter extends SubscriptionExceptionResolverAdapter { 15 | 16 | @Override 17 | protected GraphQLError resolveToSingleError(Throwable exception) { 18 | if (exception instanceof GraphQlException) { 19 | return (GraphQLError) exception; 20 | } else { 21 | return null; 22 | } 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-server/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Changing the port for the GraphQL server 2 | server.port = 8182 3 | 4 | # This should probably not be done in production 5 | security.enable.csrf = false 6 | 7 | # The line below activates the websocket support (mandatory for subscriptions) on the given path 8 | spring.graphql.websocket.path=/graphql 9 | 10 | # Enabling graphiql (from spring-graphql) 11 | spring.graphql.graphiql.enabled = true 12 | 13 | # Allowing the H2 Console (the jdbc URL to use in the console is jdbc:h2:mem:testdb) 14 | spring.h2.console.enabled=true 15 | 16 | # Prevents the SQL schema to be automatically created. With this parameter set to false, it's up to the project to build the tables, indexes... 17 | # (see the src/main/resource/schema.sql which does this job, in this sample) 18 | spring.jpa.generate-ddl=false 19 | spring.jpa.hibernate.ddl-auto=none 20 | 21 | # Necessary to avoid the hibernate "could not initialize proxy - no Session" error 22 | spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true 23 | 24 | # To generate hibernate query execution logs 25 | #spring.jpa.show-sql=true 26 | #spring.jpa.properties.hibernate.format_sql=true 27 | 28 | # Line from here: https://medium.com/geekculture/jwt-authentication-with-oauth2-resource-server-and-an-external-authorization-server-2b8fd1524fc8 29 | # spring.security.oauth2.resourceserver.jwt.jwk-set-uri = http://localhost:8181 30 | # 31 | spring.security.oauth2.resourceserver.jwt.issuer-uri: http://localhost:8181 32 | 33 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-server/src/main/resources/data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphql-java-generator/graphql-gradle-plugin-project/a6fe37c08ae032c52784d38b4a121050b71f7041/graphql-gradle-plugin-samples-Forum-server/src/main/resources/data.xlsx -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-server/src/main/resources/logback-local.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 7 | 8 | 9 | 10 | target/server.log 11 | 12 | %date %level [%thread] %logger{10} [%file:%line] %msg%n 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-server/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 7 | 8 | 9 | 10 | target/server.log 11 | 12 | %date %level [%thread] %logger{10} [%file:%line] %msg%n 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-server/src/main/resources/schema.sql: -------------------------------------------------------------------------------- 1 | 2 | -- This sequence allows Hibernate to generate id values, thanks to the @GeneratedValue annotation 3 | CREATE SEQUENCE HIBERNATE_SEQUENCE START WITH 1000 INCREMENT BY 1; --useless since Hibernate 6 4 | CREATE SEQUENCE MEMBER_SEQ START WITH 1000 INCREMENT BY 50; 5 | CREATE SEQUENCE BOARD_SEQ START WITH 1000 INCREMENT BY 50; 6 | CREATE SEQUENCE TOPIC_SEQ START WITH 1000 INCREMENT BY 50; 7 | CREATE SEQUENCE POST_SEQ START WITH 1000 INCREMENT BY 50; 8 | 9 | 10 | create table member ( 11 | id long not null, 12 | name varchar(255) not null, 13 | alias varchar(255), 14 | email varchar(255) not null, 15 | type varchar(255), 16 | primary key (id) 17 | ); 18 | 19 | create table board ( 20 | id long not null, 21 | name varchar(255) not null, 22 | publicly_available boolean, 23 | primary key (id) 24 | ); 25 | 26 | create table topic ( 27 | id long not null, 28 | board_id long not null, 29 | date datetime not null, 30 | author_id long, 31 | publicly_available boolean, 32 | nb_posts int, 33 | title varchar(255) not null, 34 | content varchar(255) not null, 35 | primary key (id) 36 | ); 37 | 38 | create table post ( 39 | id long not null, 40 | date datetime not null, 41 | topic_id long not null, 42 | author_id long, 43 | publicly_available boolean, 44 | title varchar(255) not null, 45 | content varchar(255) not null, 46 | primary key (id) 47 | ); 48 | 49 | alter table topic 50 | add constraint topic_fk_board 51 | foreign key (board_id) 52 | references board 53 | ; 54 | alter table topic 55 | add constraint topic_fk_member 56 | foreign key (author_id) 57 | references member 58 | ; 59 | alter table post 60 | add constraint post_fk_topic 61 | foreign key (topic_id) 62 | references topic 63 | ; 64 | alter table post 65 | add constraint post_fk_member 66 | foreign key (author_id) 67 | references member 68 | ; 69 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-Forum-server/src/site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | org.apache.maven.skins 7 | maven-fluido-skin 8 | 2.0.0-M5 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-OAuth-authorization-server/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java-library' 3 | id 'application' 4 | id 'com.graphql-java-generator.graphql-gradle-plugin' 5 | id 'org.springframework.boot' version "${springBootVersion}" 6 | id 'io.spring.dependency-management' version "${springDependencyManagementPluginVersion}" 7 | } 8 | 9 | repositories { 10 | // The plugin depends on the graphql-maven-plugin plugin logic module, which is in mavenCentral (for releases), and in mavenLocal 11 | // when working on the plugin development. 12 | mavenCentral() 13 | mavenLocal() // Only if you work on the plugin development 14 | } 15 | 16 | dependencies { 17 | implementation "org.springframework.boot:spring-boot-starter-web" 18 | implementation "org.springframework.boot:spring-boot-starter-security" 19 | implementation "org.springframework.security:spring-security-oauth2-authorization-server:${oauth2AuthorizationServerVersion}" 20 | 21 | // Dependencies mandatory to build with java 17 22 | implementation "com.sun.xml.bind:jaxb-impl:${jaxbImplVersion}" 23 | implementation "com.sun.xml.messaging.saaj:saaj-impl:${saajImplVersion}" 24 | 25 | // Dependencies for tests 26 | testImplementation "org.springframework.boot:spring-boot-starter-test" 27 | testImplementation "org.springframework.security:spring-security-test" 28 | } 29 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-OAuth-authorization-server/src/main/java/com/graphql_java_generator/oauth_authorization_server/AuthorizationServerMain.java: -------------------------------------------------------------------------------- 1 | package com.graphql_java_generator.oauth_authorization_server; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class AuthorizationServerMain { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(AuthorizationServerMain.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-OAuth-authorization-server/src/main/java/com/graphql_java_generator/oauth_authorization_server/DefaultSecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.graphql_java_generator.oauth_authorization_server; 2 | 3 | import static org.springframework.security.config.Customizer.withDefaults; 4 | 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 7 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 8 | import org.springframework.security.core.userdetails.User; 9 | import org.springframework.security.core.userdetails.UserDetails; 10 | import org.springframework.security.core.userdetails.UserDetailsService; 11 | import org.springframework.security.provisioning.InMemoryUserDetailsManager; 12 | import org.springframework.security.web.SecurityFilterChain; 13 | 14 | /** 15 | * @author Joe Grandja 16 | * @since 0.1.0 17 | */ 18 | @EnableWebSecurity 19 | public class DefaultSecurityConfig { 20 | 21 | @Bean 22 | SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Exception { 23 | http.authorizeRequests(// 24 | authorizeRequests -> authorizeRequests// 25 | .antMatchers("/helloWorld").anonymous()// 26 | .anyRequest().authenticated()// 27 | ).formLogin(withDefaults()); 28 | return http.build(); 29 | } 30 | 31 | @Bean 32 | UserDetailsService users() { 33 | UserDetails user = User.withDefaultPasswordEncoder().username("user1").password("password").roles("USER") 34 | .build(); 35 | return new InMemoryUserDetailsManager(user); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-OAuth-authorization-server/src/main/java/com/graphql_java_generator/oauth_authorization_server/HelloWorldController.java: -------------------------------------------------------------------------------- 1 | package com.graphql_java_generator.oauth_authorization_server; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.ResponseBody; 6 | 7 | /** 8 | * This class is a "almost useless" one. It has no use within the Authorization server. It's only use as a "life page", 9 | * so that we can check that the Authorization server is properly started, when running the integration tests. 10 | * 11 | * @author etienne-sf 12 | * 13 | */ 14 | @Controller 15 | public class HelloWorldController { 16 | 17 | @RequestMapping(value = "/helloWorld") 18 | @ResponseBody 19 | public String helloWorld() { 20 | return "Hello World!"; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-OAuth-authorization-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8181 3 | 4 | #spring: 5 | # security: 6 | # oauth2: 7 | # resourceserver: 8 | # opaquetoken: 9 | # introspection-uri: /tokenIntrospection 10 | # client-id: clientId 11 | # client-secret: secret 12 | 13 | oauth2: 14 | clientId: clientId 15 | clientSecret: secret 16 | 17 | logging: 18 | level: 19 | root: INFO 20 | org.springframework: DEBUG 21 | org.springframework.web: DEBUG 22 | org.springframework.security: TRACE 23 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-OAuth-authorization-server/src/main/resources/logback-local.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 10 | 11 | 12 | 13 | target/server.log 14 | 15 | %date %level [%thread] %logger{10} [%file:%line] %msg%n 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-OAuth-authorization-server/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 7 | 8 | 9 | 10 | target/server.log 11 | 12 | %date %level [%thread] %logger{10} [%file:%line] %msg%n 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /build2/ 3 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/CustomTemplates-resttemplate/readme.md: -------------------------------------------------------------------------------- 1 | # Explanation 2 | 3 | This template is a copy/paste of the 'client_query_mutation_type.vm.java' template, as it is redefined in the 4 | `graphql-maven-plugin-samples-CustomTemplates-resttemplate` module of the maven plugin project. 5 | 6 | Like in the maven plugin project, this custom template should come from an external project. But custom templates embedded 7 | in an external library doesn't seem to be readable from a Gradle plugin, so this custom template has been copied into the ./CustomTemplates-resttemplate of this project, so that the JUnit tests coming from the Maven project still work. 8 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/graphqls/allGraphQLCases/allGraphQLCases_extends.graphqls: -------------------------------------------------------------------------------- 1 | 2 | extend type MyQueryType { 3 | 4 | ################################################################################ 5 | # A particular test, based on the github schema: a query that returns the query object. 6 | # It introduces complexity in the code generation, that must be tested 7 | relay: MyQueryType! 8 | } 9 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/graphqls/customtemplates/readme.md: -------------------------------------------------------------------------------- 1 | # Explanation 2 | 3 | This template is a copy/paste of the 'client_subscription_type.vm.java' template, with this only modification: 4 | * Add of a boolean field: thisIsADummyFieldToCheckThatThisTemplateIsUsed. It is checked in the IT test, to check that the custom templates is actually used. 5 | 6 | 7 | # Internal note 8 | 9 | # To update it : 10 | 11 | * Copy/paste the `client_subscription_type.vm.java` template, from the plugin-logic module. 12 | * Add the thisIsADummyFieldToCheckThatThisTemplateIsUsed just after the class declaration, like this : 13 | 14 | ```Java 15 | ${object.annotation} 16 | @SuppressWarnings("unused") 17 | public class ${object.classSimpleName} extends ${object.name}Executor${springBeanSuffix} #if(!${configuration.separateUtilityClasses} && ${object.requestType})implements com.graphql_java_generator.client.GraphQLRequestObject #end{ 18 | 19 | /** 20 | * The field below is the only change from the original template. It is here only to check that 21 | * this template is actually used 22 | */ 23 | public boolean thisIsADummyFieldToCheckThatThisTemplateIsUsed = true; 24 | 25 | ``` 26 | 27 | ## To document it 28 | 29 | A good idea is to add these lines at the beginning of the file, for documentation: 30 | 31 | ```md 32 | ## 33 | ## This template is a copy/paste of the 'client_subscription_type.vm.java' template, with this only modification: 34 | ## - Add of a boolean field: thisIsADummyFieldToCheckThatThisTemplateIsUsed. It is checked in the IT test, 35 | ## to check that the custom templates is actually used. 36 | ## 37 | ``` 38 | 39 | ## To test it 40 | 41 | The `com.graphql_java_generator.samples.basic.client.ValidateCustomQueryIT` integration test checks that the thisIsADummyFieldToCheckThatThisTemplateIsUsed is true, which implies that the field exists, and so that the custom templates has been used to generate the code. -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/graphqls/forum/forum.graphqls: -------------------------------------------------------------------------------- 1 | scalar Date 2 | 3 | type Query { 4 | boards: [Board] 5 | nbBoards: Int 6 | topics(boardName: String!): [Topic]! 7 | findTopics(boardName: String!, keyword: [String!]): [Topic] 8 | } 9 | 10 | type Mutation { 11 | createBoard(name: String!, publiclyAvailable: Boolean): Board! 12 | createTopic(topic: TopicInput): Topic! 13 | createPost(post: PostInput!): Post! 14 | createPosts(spam: [PostInput!]!): [Post!]! 15 | createMember(input: MemberInput!): Member 16 | } 17 | 18 | type Subscription { 19 | subscribeToNewPost(boardName: String!): Post! 20 | } 21 | 22 | enum MemberType { 23 | ADMIN 24 | MODERATOR 25 | STANDARD 26 | } 27 | 28 | input MemberInput { 29 | name: String! 30 | alias: String 31 | email: String! 32 | type: MemberType 33 | } 34 | 35 | type Member { 36 | id: ID! 37 | name(uppercase: Boolean): String! 38 | alias: String 39 | email: String! 40 | type: MemberType 41 | } 42 | 43 | type Board { 44 | id: ID! 45 | name: String! 46 | publiclyAvailable: Boolean 47 | topics(since: Date): [Topic]! 48 | } 49 | 50 | type Topic { 51 | id: ID! 52 | date: Date! 53 | author: Member! 54 | publiclyAvailable: Boolean 55 | nbPosts: Int 56 | title: String! 57 | content: String 58 | posts(memberId: ID, memberName: String, since: Date!): [Post]! 59 | } 60 | 61 | type Post { 62 | id: ID! 63 | date: Date! 64 | author: Member 65 | publiclyAvailable: Boolean 66 | title: String! 67 | content: String! 68 | } 69 | 70 | input TopicPostInput { 71 | authorId: ID! 72 | date: Date! 73 | publiclyAvailable: Boolean 74 | title: String! 75 | content: String! 76 | } 77 | 78 | input TopicInput { 79 | boardId: ID! 80 | input: TopicPostInput 81 | } 82 | 83 | input PostInput { 84 | topicId: ID! 85 | input: TopicPostInput 86 | from: Date 87 | in: [Date!] 88 | } 89 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/com/generated/graphql/samples/customscalar/CustomId.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.generated.graphql.samples.customscalar; 5 | 6 | /** 7 | * A class that override a String, to check custom scalars, where the Java type is not known of the plugin while 8 | * generating the code. As explained in the issues 9 | * 184 and 10 | * 198, it would 11 | * generate an error. 12 | * 13 | * @author etienne-sf 14 | * 15 | */ 16 | public class CustomId { 17 | 18 | final private String id; 19 | 20 | public CustomId(String id) { 21 | this.id = id; 22 | } 23 | 24 | public String getId() { 25 | return this.id; 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | return this.id; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/annotation/AllEnums1.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.annotation; 5 | 6 | import static java.lang.annotation.ElementType.FIELD; 7 | import static java.lang.annotation.ElementType.METHOD; 8 | import static java.lang.annotation.ElementType.PARAMETER; 9 | import static java.lang.annotation.ElementType.TYPE; 10 | 11 | import java.lang.annotation.Retention; 12 | import java.lang.annotation.RetentionPolicy; 13 | import java.lang.annotation.Target; 14 | 15 | /** 16 | * This annotation is added by the schema personalization file 17 | * 18 | * @author etienne-sf 19 | */ 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Target({ TYPE, FIELD, METHOD, PARAMETER }) 22 | public @interface AllEnums1 { 23 | 24 | public String value(); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/annotation/AllEnums2.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.annotation; 5 | 6 | import static java.lang.annotation.ElementType.FIELD; 7 | import static java.lang.annotation.ElementType.METHOD; 8 | import static java.lang.annotation.ElementType.PARAMETER; 9 | import static java.lang.annotation.ElementType.TYPE; 10 | 11 | import java.lang.annotation.Retention; 12 | import java.lang.annotation.RetentionPolicy; 13 | import java.lang.annotation.Target; 14 | 15 | /** 16 | * This annotation is added by the schema personalization file 17 | * 18 | * @author etienne-sf 19 | */ 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Target({ TYPE, FIELD, METHOD, PARAMETER }) 22 | public @interface AllEnums2 { 23 | 24 | public String value(); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/annotation/LocalAnnotation.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.annotation; 5 | 6 | import static java.lang.annotation.ElementType.FIELD; 7 | import static java.lang.annotation.ElementType.METHOD; 8 | import static java.lang.annotation.ElementType.PARAMETER; 9 | import static java.lang.annotation.ElementType.TYPE; 10 | 11 | import java.lang.annotation.Retention; 12 | import java.lang.annotation.RetentionPolicy; 13 | import java.lang.annotation.Target; 14 | 15 | /** 16 | * This annotation is added by the schema personalization file 17 | * 18 | * @author etienne-sf 19 | */ 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Target({ TYPE, FIELD, METHOD, PARAMETER }) 22 | public @interface LocalAnnotation { 23 | 24 | public String value(); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/annotation/MyAdditionalAnnotation.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.annotation; 5 | 6 | import static java.lang.annotation.ElementType.FIELD; 7 | import static java.lang.annotation.ElementType.METHOD; 8 | import static java.lang.annotation.ElementType.PARAMETER; 9 | import static java.lang.annotation.ElementType.TYPE; 10 | 11 | import java.lang.annotation.Retention; 12 | import java.lang.annotation.RetentionPolicy; 13 | import java.lang.annotation.Target; 14 | 15 | /** 16 | * This annotation is added by the schema personalization file 17 | * 18 | * @author etienne-sf 19 | */ 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Target({ TYPE, FIELD, METHOD, PARAMETER }) 22 | public @interface MyAdditionalAnnotation { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/annotation/MyReplacementAnnotation.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.annotation; 5 | 6 | import static java.lang.annotation.ElementType.FIELD; 7 | import static java.lang.annotation.ElementType.METHOD; 8 | import static java.lang.annotation.ElementType.PARAMETER; 9 | import static java.lang.annotation.ElementType.TYPE; 10 | 11 | import java.lang.annotation.Retention; 12 | import java.lang.annotation.RetentionPolicy; 13 | import java.lang.annotation.Target; 14 | 15 | /** 16 | * This annotation is added by the schema personalization file 17 | * 18 | * @author etienne-sf 19 | */ 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Target({ TYPE, FIELD, METHOD, PARAMETER }) 22 | public @interface MyReplacementAnnotation { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/demo/subscription/ExecSubscription.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.demo.subscription; 5 | 6 | import java.util.concurrent.TimeUnit; 7 | 8 | import org.allGraphQLCases.client.util.TheSubscriptionTypeExecutorAllGraphQLCases; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Component; 11 | 12 | import com.graphql_java_generator.client.SubscriptionClient; 13 | import com.graphql_java_generator.exception.GraphQLRequestExecutionException; 14 | import com.graphql_java_generator.exception.GraphQLRequestPreparationException; 15 | 16 | /** 17 | * Sample for the execution of a subscription 18 | * 19 | * @author etienne-sf 20 | */ 21 | @Component 22 | public class ExecSubscription { 23 | 24 | @Autowired 25 | TheSubscriptionTypeExecutorAllGraphQLCases subscriptionExecutor; 26 | 27 | SubscriptionCallbackListInteger callback = new SubscriptionCallbackListInteger(); 28 | 29 | public void exec() 30 | throws GraphQLRequestExecutionException, GraphQLRequestPreparationException, InterruptedException { 31 | SubscriptionClient sub = subscriptionExecutor.subscribeToAList("", callback); 32 | 33 | // Let's wait 10 seconds max, to receive some notifications (the latch is freed when the callback receives 10 34 | // notifications) 35 | callback.latchFor10Notifications.await(10, TimeUnit.SECONDS); 36 | 37 | // Of course, no exception should have been raised. 38 | if (callback.lastError != null) 39 | throw new RuntimeException(callback.lastError); 40 | 41 | // Let's disconnect from the subscription 42 | System.out.println("Let's unsubscribe"); 43 | sub.unsubscribe(); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/demo/subscription/SubscriptionCallbackListInteger.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.demo.subscription; 5 | 6 | import java.util.List; 7 | import java.util.concurrent.CountDownLatch; 8 | 9 | import com.graphql_java_generator.client.SubscriptionCallback; 10 | 11 | /** 12 | * This class will receive the items returned by the "subscribeToAList" subscription 13 | * 14 | * @author etienne-sf 15 | */ 16 | public class SubscriptionCallbackListInteger implements SubscriptionCallback> { 17 | 18 | CountDownLatch latchFor10Notifications = new CountDownLatch(10); 19 | Throwable lastError = null; 20 | 21 | @Override 22 | public void onConnect() { 23 | System.out.println("The subscription is connected"); 24 | } 25 | 26 | @Override 27 | public void onMessage(List t) { 28 | System.out.println("Received this list from the 'subscribeToAList' subscription: " + t); 29 | latchFor10Notifications.countDown(); 30 | } 31 | 32 | @Override 33 | public void onClose(int statusCode, String reason) { 34 | System.out.println("The subscription is closed"); 35 | } 36 | 37 | @Override 38 | public void onError(Throwable cause) { 39 | System.out.println("Oups! An error occurred: " + cause.getMessage()); 40 | lastError = cause; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/graphqlrepository/non_spring/GraphQLRequests.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.graphqlrepository.non_spring; 5 | 6 | import java.util.List; 7 | 8 | import org.allGraphQLCases.client.CIP_Character_CIS; 9 | import org.allGraphQLCases.client.CINP_CharacterInput_CINS; 10 | import org.allGraphQLCases.client.CINP_HumanInput_CINS; 11 | 12 | import com.graphql_java_generator.annotation.RequestType; 13 | import com.graphql_java_generator.client.graphqlrepository.BindParameter; 14 | import com.graphql_java_generator.client.graphqlrepository.FullRequest; 15 | import com.graphql_java_generator.client.graphqlrepository.GraphQLRepository; 16 | import com.graphql_java_generator.client.graphqlrepository.PartialRequest; 17 | import com.graphql_java_generator.exception.GraphQLRequestExecutionException; 18 | import org.allGraphQLCases.client.CTP_AnotherMutationType_CTS; 19 | 20 | /** 21 | * This is a demo of the use of a {@link GraphQLRepository}. It contains the definition of GraphQL requests. Doing this 22 | * hides all the wiring to prepare and execute the GraphQL requests (query/mutation/subscription). 23 | * 24 | * @author etienne-sf 25 | */ 26 | @GraphQLRepository // Useless for non-Spring app. But you can consider using it for 'documentation' 27 | public interface GraphQLRequests { 28 | 29 | @PartialRequest(request = "{appearsIn name }") 30 | public List withoutParameters() throws GraphQLRequestExecutionException; 31 | 32 | @PartialRequest(request = "{id appearsIn name}") 33 | public CIP_Character_CIS withOneOptionalParam(CINP_CharacterInput_CINS character) throws GraphQLRequestExecutionException; 34 | 35 | @FullRequest(request = "mutation {createHuman (human: &input) {id name} }", requestType = RequestType.mutation) 36 | public CTP_AnotherMutationType_CTS createHuman(@BindParameter(name = "input") CINP_HumanInput_CINS input) 37 | throws GraphQLRequestExecutionException; 38 | } 39 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/interfaces/AllInputTypes1.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface AllInputTypes1 { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/interfaces/AllInputTypes2.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface AllInputTypes2 { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/interfaces/AllInterfaces1.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface AllInterfaces1 { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/interfaces/AllInterfaces2.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface AllInterfaces2 { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/interfaces/AllTypes1.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface AllTypes1 { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/interfaces/AllTypes2.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface AllTypes2 { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/interfaces/AllUnions1.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface AllUnions1 { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/interfaces/AllUnions2.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface AllUnions2 { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/interfaces/AnyCharacterInterface.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface AnyCharacterInterface { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/interfaces/CharacterInterface.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface CharacterInterface { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/interfaces/DroidInputInterface.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface DroidInputInterface { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/interfaces/HumanInterface.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface HumanInterface { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/interfaces/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains interfaces that are used to test the schema personalization capability. These interfaces are 3 | * added to the generated classes, interfaces (...), as defined in the /src/main/graphql/schema_personalization.json 4 | * file 5 | */ 6 | package org.allGraphQLCases.interfaces; 7 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/minimal/oauth_app/MinimalOAuthApp.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.minimal.oauth_app; 5 | 6 | import java.util.List; 7 | 8 | import org.allGraphQLCases.client.CIP_Character_CIS; 9 | import org.allGraphQLCases.client.util.MyQueryTypeExecutorAllGraphQLCases; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.boot.CommandLineRunner; 14 | import org.springframework.boot.SpringApplication; 15 | import org.springframework.boot.autoconfigure.SpringBootApplication; 16 | 17 | import com.graphql_java_generator.client.GraphqlClientUtils; 18 | 19 | /** 20 | * This class describes how to create a minimal app, that can access to an OAuth2 protected GraphQL server 21 | * 22 | * @author etienne-sf 23 | */ 24 | @SpringBootApplication(scanBasePackageClasses = { MinimalOAuthApp.class, GraphqlClientUtils.class, 25 | MyQueryTypeExecutorAllGraphQLCases.class }) 26 | public class MinimalOAuthApp implements CommandLineRunner { 27 | 28 | /** The logger for this class */ 29 | static protected Logger logger = LoggerFactory.getLogger(MinimalOAuthApp.class); 30 | 31 | @Autowired 32 | MyQueryTypeExecutorAllGraphQLCases queryType; 33 | 34 | public static void main(String[] args) { 35 | SpringApplication.run(MinimalOAuthApp.class, args); 36 | } 37 | 38 | /** 39 | * This method is started by Spring, once the Spring context has been loaded. This is run, as this class implements 40 | * {@link CommandLineRunner} 41 | */ 42 | @Override 43 | public void run(String... args) throws Exception { 44 | List response; 45 | String query = "{appearsIn name }"; 46 | 47 | logger.info("Executing this query: '" + query 48 | + "' (the first GraphQL request execution is longer, as the Reactive code must be started)"); 49 | response = queryType.withoutParameters(query); 50 | logger.info(response.toString()); 51 | 52 | logger.info("Re-executing this query: '" + query + "'"); 53 | response = queryType.withoutParameters(query); 54 | logger.info(response.toString()); 55 | 56 | logger.info("Normal end of execution"); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/minimal/oauth_app/package-info.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.minimal.oauth_app; 2 | 3 | /** This package allows to create a new Spring Boot app, without interfering with the other one */ -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/minimal/spring_app/GraphQLRequests.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.minimal.spring_app; 5 | 6 | import java.util.List; 7 | 8 | import org.allGraphQLCases.client.CINP_CharacterInput_CINS; 9 | import org.allGraphQLCases.client.CINP_HumanInput_CINS; 10 | import org.allGraphQLCases.client.CIP_Character_CIS; 11 | import org.allGraphQLCases.client.CTP_AnotherMutationType_CTS; 12 | import org.allGraphQLCases.client.util.MyQueryTypeExecutorAllGraphQLCases; 13 | 14 | import com.graphql_java_generator.annotation.RequestType; 15 | import com.graphql_java_generator.client.graphqlrepository.BindParameter; 16 | import com.graphql_java_generator.client.graphqlrepository.FullRequest; 17 | import com.graphql_java_generator.client.graphqlrepository.GraphQLRepository; 18 | import com.graphql_java_generator.client.graphqlrepository.PartialRequest; 19 | import com.graphql_java_generator.exception.GraphQLRequestExecutionException; 20 | 21 | /** 22 | * This is a demo of the use of a {@link GraphQLRepository}. It contains the definition of GraphQL requests. Doing this 23 | * hides all the wiring to prepare and execute the GraphQL requests (query/mutation/subscription). Just declare a 24 | * {@link GraphQLRequests} autowired bean in your Spring component, and you can execute GraphQL requests. Take a look at 25 | * the {@link MinimalSpringApp} main class for that. 26 | * 27 | * @author etienne-sf 28 | */ 29 | @GraphQLRepository(queryExecutor = MyQueryTypeExecutorAllGraphQLCases.class) 30 | public interface GraphQLRequests { 31 | 32 | @PartialRequest(request = "{appearsIn name }") 33 | public List withoutParameters() throws GraphQLRequestExecutionException; 34 | 35 | @PartialRequest(request = "{id appearsIn name}") 36 | public CIP_Character_CIS withOneOptionalParam(CINP_CharacterInput_CINS character) 37 | throws GraphQLRequestExecutionException; 38 | 39 | @FullRequest(request = "mutation {createHuman (human: &input) {id name} }", requestType = RequestType.mutation) 40 | public CTP_AnotherMutationType_CTS createHuman(@BindParameter(name = "input") CINP_HumanInput_CINS input) 41 | throws GraphQLRequestExecutionException; 42 | } 43 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/java/org/allGraphQLCases/minimal/spring_app/package-info.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.minimal.spring_app; 2 | 3 | /** 4 | * This package contains a demo for the use of the plugin as a Spring Boot app, which is the recommended way to go.
5 | * It contains: 6 | *
    7 | *
  • GraphQLRequests: the {@link com.graphql_java_generator.annotation.GraphQLRepository} that contains the 8 | * GraphQL requests (query, mutation, subscription) used by this application. It's "just" an interface that defines the 9 | * expected methods. Behind the scene, the plugin takes care of wiring these method, and executes the relevant 10 | * code.
  • 11 | *
  • MinimalSpringApp: the application itself, that calls the 12 | * {@link org.allGraphQLCases.minimal.spring_app.GraphQLRequests} methods
  • 13 | *
  • application.properties: the application properties contain, at least, the GraphQL endpoint URL
  • 14 | *
15 | */ -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | graphql.endpointAllGraphQLCases.url = http://localhost:8180/my/updated/graphql/path 3 | graphql.endpointAllGraphQLCases2.url = http://localhost:8188/a/bad/path 4 | graphql.endpointForum.url = http://localhost:8182/graphql 5 | 6 | # We don't need the Netty web server to start (but its dependencies are mandatory) 7 | spring.main.web-application-type = none 8 | 9 | # Configuration of the WebClient 10 | # In order to raise the volume of the in-memory buffer to manager large server responses, and depending on your configuration, you can : 11 | # use the 'spring.codec.max-in-memory-size' parameter or change your WebClient definition. 12 | # See https://github.com/spring-projects/spring-framework/issues/23961 13 | # spring.codec.max-in-memory-size = 10MB 14 | 15 | # Configuration for OAuth2, for our local OAuth authorization server 16 | spring.security.oauth2.client.registration.provider_test.authorization-grant-type=client_credentials 17 | spring.security.oauth2.client.registration.provider_test.client-id=clientId 18 | spring.security.oauth2.client.registration.provider_test.client-secret=secret 19 | #spring.security.oauth2.client.registration.provider_test.scope=ROLE_CLIENT 20 | 21 | # Definition of the token provider url 22 | spring.security.oauth2.client.provider.provider_test.token-uri=http://localhost:8181/oauth2/token 23 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %message%n 7 | 8 | 9 | 10 | target2/client.log 11 | 12 | %date %level [%thread] %logger{10} [%file:%line] %msg%n 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | org.apache.maven.skins 6 | maven-fluido-skin 7 | 2.0.0-M5 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/test/java/com/graphql_java_generator/samples/forum/test/client/subscription/PostSubscriptionCallback.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.graphql_java_generator.samples.forum.test.client.subscription; 5 | 6 | import java.util.concurrent.CountDownLatch; 7 | 8 | import org.forum.client.Post; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | 12 | import com.graphql_java_generator.client.SubscriptionCallback; 13 | 14 | /** 15 | * @author etienne-sf 16 | */ 17 | // The class that'll receive the notification from the GraphQL subscription 18 | 19 | public class PostSubscriptionCallback implements SubscriptionCallback { 20 | 21 | /** The logger for this class */ 22 | static protected Logger logger = LoggerFactory.getLogger(PostSubscriptionCallback.class); 23 | 24 | /** Indicates whether the Web Socket is connected or not */ 25 | public boolean connected = false; 26 | 27 | public int nbReceivedMessages = 0; 28 | public Post lastReceivedMessage = null; 29 | public String lastReceivedClose = null; 30 | public Throwable lastReceivedError = null; 31 | 32 | public CountDownLatch latchNewMessage = new CountDownLatch(1); 33 | 34 | @Override 35 | public void onConnect() { 36 | this.connected = true; 37 | logger.debug("The 'subscribeToNewPostWithBindValues' subscription is now active (the web socket is connected)"); 38 | } 39 | 40 | @Override 41 | public void onMessage(Post t) { 42 | logger.debug( 43 | "Received a notification from the 'subscribeToNewPostWithBindValues' subscription, for this post {} ", 44 | t); 45 | nbReceivedMessages += 1; 46 | lastReceivedMessage = t; 47 | latchNewMessage.countDown(); 48 | // Do something useful with it 49 | } 50 | 51 | @Override 52 | public void onClose(int statusCode, String reason) { 53 | connected = false; 54 | lastReceivedClose = statusCode + "-" + reason; 55 | logger.debug("Received onClose: {}", lastReceivedClose); 56 | } 57 | 58 | @Override 59 | public void onError(Throwable cause) { 60 | connected = false; 61 | lastReceivedError = cause; 62 | logger.debug("Received onError: {}", cause); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/test/java/org/allGraphQLCases/GraphQLTypeMappingTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | import static org.junit.jupiter.api.Assertions.assertNotNull; 8 | 9 | import org.allGraphQLCases.client.util.GraphQLTypeMapping; 10 | import org.junit.jupiter.api.Test; 11 | 12 | /** 13 | * @author etienne-sf 14 | */ 15 | public class GraphQLTypeMappingTest { 16 | 17 | @Test 18 | void test_getResourceAsStream() throws ClassNotFoundException { 19 | final String RESOURCE_PATH = "typeMappingAllGraphQLCases.csv"; 20 | ClassLoader classLoader = GraphQLTypeMapping.class.getClassLoader(); 21 | assertNotNull(classLoader.getResourceAsStream(RESOURCE_PATH)); 22 | } 23 | 24 | @Test 25 | void test_GraphQLTypeMapping() throws ClassNotFoundException { 26 | assertEquals("org.allGraphQLCases.client.CTP_break_CTS", GraphQLTypeMapping.getJavaClass("break").getName()); 27 | assertEquals("org.allGraphQLCases.client.CEP_extends_CES", 28 | GraphQLTypeMapping.getJavaClass("extends").getName()); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/test/java/org/allGraphQLCases/graphqlrepositories/GraphQLReactiveRepositoryFullRequests.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.graphqlrepositories; 5 | 6 | import org.allGraphQLCases.client.CINP_CharacterInput_CINS; 7 | import org.allGraphQLCases.client.CINP_HumanInput_CINS; 8 | import org.allGraphQLCases.client.CTP_AnotherMutationType_CTS; 9 | import org.allGraphQLCases.client.CTP_MyQueryType_CTS; 10 | import org.allGraphQLCases.client.util.MyQueryTypeReactiveExecutorAllGraphQLCases; 11 | 12 | import com.graphql_java_generator.annotation.RequestType; 13 | import com.graphql_java_generator.client.graphqlrepository.BindParameter; 14 | import com.graphql_java_generator.client.graphqlrepository.FullRequest; 15 | import com.graphql_java_generator.client.graphqlrepository.GraphQLReactiveRepository; 16 | import com.graphql_java_generator.exception.GraphQLRequestExecutionException; 17 | 18 | import reactor.core.publisher.Mono; 19 | 20 | /** 21 | * This interface demonstrate the use of {@link GraphQLReactiveRepository}: it implements a unique Full Requests that is 22 | * a subscription. 23 | * 24 | * @author etienne-sf 25 | */ 26 | @GraphQLReactiveRepository(queryExecutor = MyQueryTypeReactiveExecutorAllGraphQLCases.class) 27 | public interface GraphQLReactiveRepositoryFullRequests { 28 | 29 | @FullRequest(request = "{withoutParameters{appearsIn name} withOneOptionalParam(character: &character){id name appearsIn friends {id name}}}") 30 | Mono fullRequestQuery(// 31 | @BindParameter(name = "character") CINP_CharacterInput_CINS character// 32 | ) throws GraphQLRequestExecutionException; 33 | 34 | @FullRequest(request = "mutation { createHuman(human:&human) {id name}}", requestType = RequestType.mutation) 35 | Mono fullRequestMutation(// 36 | @BindParameter(name = "human") CINP_HumanInput_CINS human// 37 | ) throws GraphQLRequestExecutionException; 38 | 39 | // Subscription are tested in the org.allGraphQLCases.subscription.graphqlrepository package 40 | } 41 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/test/java/org/allGraphQLCases/graphqlrepositories/GraphQLRepositoryFullRequests.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.graphqlrepositories; 5 | 6 | import org.allGraphQLCases.client.CINP_CharacterInput_CINS; 7 | import org.allGraphQLCases.client.CINP_HumanInput_CINS; 8 | import org.allGraphQLCases.client.CTP_AnotherMutationType_CTS; 9 | import org.allGraphQLCases.client.CTP_MyQueryType_CTS; 10 | import org.allGraphQLCases.client.util.MyQueryTypeExecutorAllGraphQLCases; 11 | 12 | import com.graphql_java_generator.annotation.RequestType; 13 | import com.graphql_java_generator.client.graphqlrepository.BindParameter; 14 | import com.graphql_java_generator.client.graphqlrepository.FullRequest; 15 | import com.graphql_java_generator.client.graphqlrepository.GraphQLRepository; 16 | import com.graphql_java_generator.exception.GraphQLRequestExecutionException; 17 | 18 | /** 19 | * This interface demonstrates the use of {@link GraphQLRepository}. 20 | * 21 | * @author etienne-sf 22 | */ 23 | @GraphQLRepository(queryExecutor = MyQueryTypeExecutorAllGraphQLCases.class) 24 | public interface GraphQLRepositoryFullRequests { 25 | 26 | @FullRequest(request = "{withoutParameters{appearsIn name} withOneOptionalParam(character: &character){id name appearsIn friends {id name}}}") 27 | public CTP_MyQueryType_CTS fullRequestQuery(// 28 | @BindParameter(name = "character") CINP_CharacterInput_CINS character// 29 | ) throws GraphQLRequestExecutionException; 30 | 31 | @FullRequest(request = "mutation { createHuman(human:&human) {id name}}", requestType = RequestType.mutation) 32 | CTP_AnotherMutationType_CTS fullRequestMutation(// 33 | @BindParameter(name = "human") CINP_HumanInput_CINS human// 34 | ) throws GraphQLRequestExecutionException; 35 | 36 | // Subscription are tested in the org.allGraphQLCases.subscription.graphqlrepository package 37 | } 38 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/test/java/org/allGraphQLCases/impl/PartialDirectQueriesIT.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.impl; 2 | 3 | import org.allGraphQLCases.demo.PartialQueries; 4 | import org.allGraphQLCases.demo.impl.PartialDirectQueries; 5 | import org.junit.jupiter.api.parallel.Execution; 6 | import org.junit.jupiter.api.parallel.ExecutionMode; 7 | 8 | /** 9 | * As it is suffixed by "IT", this is an integration test. Thus, it allows us to start the GraphQL StatWars server, see 10 | * the pom.xml file for details. 11 | * 12 | * @author etienne-sf 13 | */ 14 | @Execution(ExecutionMode.CONCURRENT) 15 | class PartialDirectQueriesIT extends AbstractIT { 16 | 17 | @Override 18 | protected PartialQueries getQueries() { 19 | return ctx.getBean(PartialDirectQueries.class); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/test/java/org/allGraphQLCases/impl/PartialPreparedQueriesDeprecatedWayIT.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.impl; 2 | 3 | import org.allGraphQLCases.demo.PartialQueries; 4 | import org.allGraphQLCases.demo.impl.PartialPreparedQueriesDeprecatedWay; 5 | import org.junit.jupiter.api.parallel.Execution; 6 | import org.junit.jupiter.api.parallel.ExecutionMode; 7 | 8 | /** 9 | * As it is suffixed by "IT", this is an integration test. Thus, it allows us to start the GraphQL StatWars server, see 10 | * the pom.xml file for details. 11 | * 12 | * @author etienne-sf 13 | */ 14 | @Execution(ExecutionMode.CONCURRENT) 15 | class PartialPreparedQueriesDeprecatedWayIT extends AbstractIT { 16 | 17 | @Override 18 | protected PartialQueries getQueries() { 19 | return ctx.getBean(PartialPreparedQueriesDeprecatedWay.class); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/test/java/org/allGraphQLCases/impl/PartialPreparedQueriesIT.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.impl; 2 | 3 | import org.allGraphQLCases.demo.PartialQueries; 4 | import org.allGraphQLCases.demo.impl.PartialPreparedQueries; 5 | import org.junit.jupiter.api.parallel.Execution; 6 | import org.junit.jupiter.api.parallel.ExecutionMode; 7 | 8 | /** 9 | * As it is suffixed by "IT", this is an integration test. Thus, it allows us to start the GraphQL StatWars server, see 10 | * the pom.xml file for details. 11 | * 12 | * @author etienne-sf 13 | */ 14 | @Execution(ExecutionMode.CONCURRENT) 15 | class PartialPreparedQueriesIT extends AbstractIT { 16 | 17 | @Override 18 | protected PartialQueries getQueries() { 19 | return ctx.getBean(PartialPreparedQueries.class); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/test/java/org/allGraphQLCases/impl/PartialRequestGraphQLRepositoryIT.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.impl; 2 | 3 | import org.allGraphQLCases.demo.PartialQueries; 4 | import org.allGraphQLCases.demo.impl.PartialRequestGraphQLRepository; 5 | import org.junit.jupiter.api.parallel.Execution; 6 | import org.junit.jupiter.api.parallel.ExecutionMode; 7 | 8 | /** 9 | * As it is suffixed by "IT", this is an integration test. Thus, it allows us to start the GraphQL StatWars server, see 10 | * the pom.xml file for details. 11 | * 12 | * @author etienne-sf 13 | */ 14 | @Execution(ExecutionMode.CONCURRENT) 15 | class PartialRequestGraphQLRepositoryIT extends AbstractIT { 16 | 17 | @Override 18 | protected PartialQueries getQueries() { 19 | return ctx.getBean(PartialRequestGraphQLRepository.class); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/test/java/org/allGraphQLCases/subscription/SubscribeToADate.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.subscription; 2 | 3 | import java.util.Date; 4 | import java.util.concurrent.TimeUnit; 5 | 6 | import org.allGraphQLCases.client.util.TheSubscriptionTypeExecutorAllGraphQLCases; 7 | 8 | import com.graphql_java_generator.client.SubscriptionClient; 9 | import com.graphql_java_generator.exception.GraphQLRequestExecutionException; 10 | import com.graphql_java_generator.exception.GraphQLRequestPreparationException; 11 | 12 | public class SubscribeToADate implements Runnable { 13 | final TheSubscriptionTypeExecutorAllGraphQLCases subscriptionExecutor; 14 | final SubscriptionCallbackGeneric callback; 15 | final String clientName; 16 | final Date date; 17 | 18 | public SubscribeToADate(TheSubscriptionTypeExecutorAllGraphQLCases executor, String clientName, Date date) { 19 | this.subscriptionExecutor = executor; 20 | this.clientName = clientName; 21 | this.callback = new SubscriptionCallbackGeneric<>(clientName); 22 | this.date = date; 23 | } 24 | 25 | @Override 26 | public void run() { 27 | try { 28 | SubscriptionClient sub = this.subscriptionExecutor.issue53("", this.callback, this.date); 29 | 30 | // Let's wait a max of 20 second, until we receive some notifications 31 | // (20s will never occur... unless using the debugger to undebug some stuff) 32 | this.callback.latchForMessageReception.await(10, TimeUnit.SECONDS); 33 | 34 | // Let's disconnect from the subscription 35 | sub.unsubscribe(); 36 | } catch (GraphQLRequestExecutionException | GraphQLRequestPreparationException | InterruptedException e) { 37 | throw new RuntimeException(e.getMessage(), e); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/test/java/org/allGraphQLCases/subscription/graphqlrepository/SubscriptionGraphQLReactiveRepository.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.subscription.graphqlrepository; 5 | 6 | import java.util.Optional; 7 | 8 | import org.allGraphQLCases.client.CEP_EnumWithReservedJavaKeywordAsValues_CES; 9 | import org.allGraphQLCases.client.CTP_TheSubscriptionType_CTS; 10 | import org.allGraphQLCases.client.util.MyQueryTypeReactiveExecutorAllGraphQLCases; 11 | 12 | import com.graphql_java_generator.annotation.RequestType; 13 | import com.graphql_java_generator.client.graphqlrepository.FullRequest; 14 | import com.graphql_java_generator.client.graphqlrepository.GraphQLReactiveRepository; 15 | import com.graphql_java_generator.client.graphqlrepository.PartialRequest; 16 | import com.graphql_java_generator.exception.GraphQLRequestExecutionException; 17 | 18 | import reactor.core.publisher.Flux; 19 | 20 | /** 21 | * This interface demonstrates the use of {@link GraphQLReactiveRepository}: it implements a unique Full Requests that 22 | * is a subscription. 23 | * 24 | * @author etienne-sf 25 | */ 26 | @GraphQLReactiveRepository(queryExecutor = MyQueryTypeReactiveExecutorAllGraphQLCases.class) 27 | public interface SubscriptionGraphQLReactiveRepository { 28 | 29 | @FullRequest(request = "subscription {subscribeToAList {}}", requestType = RequestType.subscription) 30 | public Flux subscribeToAList() throws GraphQLRequestExecutionException; 31 | 32 | @PartialRequest(request = "", requestType = RequestType.subscription) 33 | public Flux> returnEnum() 34 | throws GraphQLRequestExecutionException; 35 | 36 | @PartialRequest(request = "", requestType = RequestType.subscription) 37 | public Flux> returnMandatoryEnum( 38 | CEP_EnumWithReservedJavaKeywordAsValues_CES _enum) throws GraphQLRequestExecutionException; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/test/java/org/allGraphQLCases/subscription/graphqlrepository/SubscriptionGraphQLRepository.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.subscription.graphqlrepository; 5 | 6 | import org.allGraphQLCases.client.CEP_EnumWithReservedJavaKeywordAsValues_CES; 7 | import org.allGraphQLCases.client.util.MyQueryTypeExecutorAllGraphQLCases; 8 | 9 | import com.graphql_java_generator.annotation.RequestType; 10 | import com.graphql_java_generator.client.SubscriptionCallback; 11 | import com.graphql_java_generator.client.SubscriptionClient; 12 | import com.graphql_java_generator.client.graphqlrepository.FullRequest; 13 | import com.graphql_java_generator.client.graphqlrepository.GraphQLRepository; 14 | import com.graphql_java_generator.client.graphqlrepository.PartialRequest; 15 | import com.graphql_java_generator.exception.GraphQLRequestExecutionException; 16 | 17 | /** 18 | * This interface demonstrates the use of GraphqlRepository: it implements subscriptions, with both Partial and Full 19 | * Requests. 20 | * 21 | * @author etienne-sf 22 | */ 23 | @GraphQLRepository(queryExecutor = MyQueryTypeExecutorAllGraphQLCases.class) 24 | public interface SubscriptionGraphQLRepository { 25 | 26 | @FullRequest(request = "subscription {subscribeToAList {}}", requestType = RequestType.subscription) 27 | public SubscriptionClient subscribeToAList(SubscriptionCallback callback) 28 | throws GraphQLRequestExecutionException; 29 | 30 | @PartialRequest(request = "", requestType = RequestType.subscription) 31 | public SubscriptionClient returnEnum(SubscriptionCallback callback) throws GraphQLRequestExecutionException; 32 | 33 | @PartialRequest(request = "", requestType = RequestType.subscription) 34 | public SubscriptionClient returnMandatoryEnum(SubscriptionCallback callback, 35 | CEP_EnumWithReservedJavaKeywordAsValues_CES _enum) throws GraphQLRequestExecutionException; 36 | } 37 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/test/java/org/allGraphQLCases/subscription/graphqlrepository/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains test for subscription defined in a 3 | * {@link com.graphql_java_generator.client.graphqlrepository.GraphQLRepository} annotated class. 4 | */ 5 | package org.allGraphQLCases.subscription.graphqlrepository; -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/test/java/org/allGraphQLCases/two_graphql_servers/GraphQLRepoAllGraphQLCases.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.two_graphql_servers; 5 | 6 | import org.allGraphQLCases.client.util.MyQueryTypeExecutorAllGraphQLCases; 7 | 8 | import com.graphql_java_generator.annotation.RequestType; 9 | import com.graphql_java_generator.client.SubscriptionCallback; 10 | import com.graphql_java_generator.client.SubscriptionClient; 11 | import com.graphql_java_generator.client.graphqlrepository.FullRequest; 12 | import com.graphql_java_generator.client.graphqlrepository.GraphQLRepository; 13 | import com.graphql_java_generator.exception.GraphQLRequestExecutionException; 14 | 15 | /** 16 | * This is a GraphQL Repository that is based on the forum GraphQL schema, thanks to the {@link QueryTypeExecutor} class 17 | * provided to the {@link GraphQLRepository} annotation. 18 | * 19 | * @author etienne-sf 20 | */ 21 | @GraphQLRepository(queryExecutor = MyQueryTypeExecutorAllGraphQLCases.class) 22 | public interface GraphQLRepoAllGraphQLCases { 23 | 24 | @FullRequest(request = "subscription {subscribeToAList {}}", requestType = RequestType.subscription) 25 | SubscriptionClient subscribeToAList(SubscriptionCallback callback) throws GraphQLRequestExecutionException; 26 | } 27 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/test/java/org/allGraphQLCases/two_graphql_servers/GraphQLRepoForum.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.two_graphql_servers; 5 | 6 | import java.util.Date; 7 | import java.util.List; 8 | 9 | import org.forum.client.Topic; 10 | import org.forum.client.QueryExecutorForum; 11 | 12 | import com.graphql_java_generator.client.graphqlrepository.BindParameter; 13 | import com.graphql_java_generator.client.graphqlrepository.GraphQLRepository; 14 | import com.graphql_java_generator.client.graphqlrepository.PartialRequest; 15 | import com.graphql_java_generator.exception.GraphQLRequestExecutionException; 16 | import com.graphql_java_generator.exception.GraphQLRequestPreparationException; 17 | 18 | /** 19 | * This is a GraphQL Repository that is based on the allGraphQLCases GraphQL schema, thanks to the 20 | * {@link QueryTypeExecutorForum} class provided to the {@link GraphQLRepository} annotation. 21 | * 22 | * @author etienne-sf 23 | */ 24 | @GraphQLRepository(queryExecutor = QueryExecutorForum.class) 25 | public interface GraphQLRepoForum { 26 | 27 | @PartialRequest(requestName = "topics", request = "{id date author{name email alias id type} nbPosts title content " // 28 | + "posts(since: &sinceParam){id date author{name email alias} title content}}") 29 | List topicAuthorPostAuthor(String boardName, @BindParameter(name = "sinceParam") Date since) 30 | throws GraphQLRequestPreparationException, GraphQLRequestExecutionException; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/test/java/org/allGraphQLCases/two_graphql_servers/package-info.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.two_graphql_servers; -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/test/java/org/forum/customtemplates/ValidateCustomQueryIT.java: -------------------------------------------------------------------------------- 1 | package org.forum.customtemplates; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertNotNull; 4 | import static org.junit.jupiter.api.Assertions.assertTrue; 5 | 6 | import java.util.List; 7 | 8 | import org.allGraphQLCases.SpringTestConfig; 9 | import org.forum.client.Board; 10 | import org.forum.client.Query; 11 | import org.forum.client.QueryExecutorForum; 12 | import org.forum.client.Subscription; 13 | import org.junit.jupiter.api.Test; 14 | import org.junit.jupiter.api.parallel.Execution; 15 | import org.junit.jupiter.api.parallel.ExecutionMode; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.boot.test.context.SpringBootTest; 18 | 19 | import com.graphql_java_generator.exception.GraphQLRequestExecutionException; 20 | import com.graphql_java_generator.exception.GraphQLRequestPreparationException; 21 | 22 | @SpringBootTest(classes = SpringTestConfig.class, webEnvironment = SpringBootTest.WebEnvironment.NONE) 23 | @Execution(ExecutionMode.CONCURRENT) 24 | class ValidateCustomQueryIT { 25 | 26 | @Autowired 27 | QueryExecutorForum query; 28 | 29 | @Test 30 | @SuppressWarnings("static-method") 31 | void test_customTemplateInTheProject() throws GraphQLRequestPreparationException, GraphQLRequestExecutionException { 32 | // Let's check that our QueryType is generated from the custom template 33 | assertTrue(new Subscription().thisIsADummyFieldToCheckThatThisTemplateIsUsed); 34 | } 35 | 36 | @Test 37 | void test_customTemplateInAnExternalJar() 38 | throws GraphQLRequestPreparationException, GraphQLRequestExecutionException { 39 | // Let's check that our QueryType is generated from the custom template 40 | assertTrue(new Query().thisIsADummyFieldToCheckThatThisTemplateIsUsed); 41 | 42 | // And that it still works! :) 43 | List response = this.query.boards("{id name}"); 44 | assertNotNull(response); 45 | assertTrue(response.size() > 0); 46 | assertTrue(response.get(0) instanceof Board); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | # ClassOrderer$OrderAnnotation sorts classes based on their @Order annotation 2 | junit.jupiter.testclass.order.default=org.junit.jupiter.api.ClassOrderer$OrderAnnotation 3 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-client/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 7 | 8 | 9 | 10 | false 11 | target2/JUnit-BeanPostProcessor.log 12 | 13 | %date [%thread] %msg%n 14 | 15 | 16 | 17 | false 18 | target2/JUnit-tests.log 19 | 20 | %date %level [%thread] %logger{10} [%file:%line] %msg%n 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-pojo-client-jackson/src/main/java/com/generated/graphql/samples/customscalar/CustomId.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.generated.graphql.samples.customscalar; 5 | 6 | /** 7 | * A class that override a String, to check custom scalars, where the Java type is not known of the plugin while 8 | * generating the code. As explained in the issues 9 | * 184 and 10 | * 198, it would 11 | * generate an error. 12 | * 13 | * @author etienne-sf 14 | * 15 | */ 16 | public class CustomId { 17 | 18 | final private String id; 19 | 20 | public CustomId(String id) { 21 | this.id = id; 22 | } 23 | 24 | public String getId() { 25 | return this.id; 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | return this.id; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-pojo-client-jackson/src/test/java/org/allGraphQLCases/client/pojo/PojoTest.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.client.pojo; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertNotNull; 4 | 5 | import java.lang.reflect.Field; 6 | 7 | import org.junit.jupiter.api.Test; 8 | 9 | import com.fasterxml.jackson.annotation.JsonProperty; 10 | 11 | class PojoTest { 12 | 13 | private AllFieldCases allFieldCases; 14 | 15 | // The simple fact that this class compiles proves that the code is properly generated. 16 | // There is just a test to check that the jackson annotation have been generated 17 | 18 | @Test 19 | void testJacksonAnnotations() throws NoSuchFieldException, SecurityException { 20 | Field id = AllFieldCases.class.getDeclaredField("id"); 21 | assertNotNull(id, "The id field must exist and be accessible"); 22 | 23 | JsonProperty jsonProp = id.getAnnotation(JsonProperty.class); 24 | assertNotNull(jsonProp, "The JsonProperty must have been defined"); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-pojo-client/.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-pojo-client/src/main/java/com/generated/graphql/samples/customscalar/CustomId.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.generated.graphql.samples.customscalar; 5 | 6 | /** 7 | * A class that override a String, to check custom scalars, where the Java type is not known of the plugin while 8 | * generating the code. As explained in the issues 9 | * 184 and 10 | * 198, it would 11 | * generate an error. 12 | * 13 | * @author etienne-sf 14 | * 15 | */ 16 | public class CustomId { 17 | 18 | final private String id; 19 | 20 | public CustomId(String id) { 21 | this.id = id; 22 | } 23 | 24 | public String getId() { 25 | return this.id; 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | return this.id; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-pojo-client/src/test/java/org/forum/pojo/PojoTest.java: -------------------------------------------------------------------------------- 1 | package org.forum.pojo; 2 | 3 | import org.allGraphQLCases.client.pojo.AllFieldCases; 4 | 5 | class PojoTest { 6 | 7 | private AllFieldCases allFieldCases; 8 | 9 | // No test execution: the simple fact that this class compiles is enough. 10 | 11 | } 12 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-pojo-server/.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-pojo-server/src/main/java/com/generated/graphql/samples/customscalar/CustomId.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.generated.graphql.samples.customscalar; 5 | 6 | /** 7 | * A class that override a String, to check custom scalars, where the Java type is not known of the plugin while 8 | * generating the code. As explained in the issues 9 | * 184 and 10 | * 198, it would 11 | * generate an error. 12 | * 13 | * @author etienne-sf 14 | * 15 | */ 16 | public class CustomId { 17 | 18 | final private String id; 19 | 20 | public CustomId(String id) { 21 | this.id = id; 22 | } 23 | 24 | public String getId() { 25 | return this.id; 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | return this.id; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-pojo-server/src/test/java/org/forum/pojo/PojoTest.java: -------------------------------------------------------------------------------- 1 | package org.forum.pojo; 2 | 3 | import org.allGraphQLCases.server.pojo.AllFieldCases; 4 | 5 | class PojoTest { 6 | 7 | private AllFieldCases allFieldCases; 8 | 9 | // No test execution: the simple fact that this class compiles is enough. 10 | 11 | } 12 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/com/generated/graphql/samples/customscalar/CustomId.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.generated.graphql.samples.customscalar; 5 | 6 | /** 7 | * A class that override a String, to check custom scalars, where the Java type is not known of the plugin while 8 | * generating the code. As explained in the issues 9 | * 184 and 10 | * 198, it would 11 | * generate an error. 12 | * 13 | * @author etienne-sf 14 | * 15 | */ 16 | public class CustomId { 17 | 18 | final private String id; 19 | 20 | public CustomId(String id) { 21 | this.id = id; 22 | } 23 | 24 | public String getId() { 25 | return this.id; 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | return this.id; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/annotation/AllEnums1.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.annotation; 5 | 6 | import static java.lang.annotation.ElementType.FIELD; 7 | import static java.lang.annotation.ElementType.METHOD; 8 | import static java.lang.annotation.ElementType.PARAMETER; 9 | import static java.lang.annotation.ElementType.TYPE; 10 | 11 | import java.lang.annotation.Retention; 12 | import java.lang.annotation.RetentionPolicy; 13 | import java.lang.annotation.Target; 14 | 15 | /** 16 | * This annotation is added by the schema personalization file 17 | * 18 | * @author etienne-sf 19 | */ 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Target({ TYPE, FIELD, METHOD, PARAMETER }) 22 | public @interface AllEnums1 { 23 | 24 | public String value(); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/annotation/AllEnums2.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.annotation; 5 | 6 | import static java.lang.annotation.ElementType.FIELD; 7 | import static java.lang.annotation.ElementType.METHOD; 8 | import static java.lang.annotation.ElementType.PARAMETER; 9 | import static java.lang.annotation.ElementType.TYPE; 10 | 11 | import java.lang.annotation.Retention; 12 | import java.lang.annotation.RetentionPolicy; 13 | import java.lang.annotation.Target; 14 | 15 | /** 16 | * This annotation is added by the schema personalization file 17 | * 18 | * @author etienne-sf 19 | */ 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Target({ TYPE, FIELD, METHOD, PARAMETER }) 22 | public @interface AllEnums2 { 23 | 24 | public String value(); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/annotation/LocalAnnotation.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.annotation; 5 | 6 | import static java.lang.annotation.ElementType.FIELD; 7 | import static java.lang.annotation.ElementType.METHOD; 8 | import static java.lang.annotation.ElementType.PARAMETER; 9 | import static java.lang.annotation.ElementType.TYPE; 10 | 11 | import java.lang.annotation.Retention; 12 | import java.lang.annotation.RetentionPolicy; 13 | import java.lang.annotation.Target; 14 | 15 | /** 16 | * This annotation is added by the schema personalization file 17 | * 18 | * @author etienne-sf 19 | */ 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Target({ TYPE, FIELD, METHOD, PARAMETER }) 22 | public @interface LocalAnnotation { 23 | 24 | public String value(); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/annotation/MyAdditionalAnnotation.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.annotation; 5 | 6 | import static java.lang.annotation.ElementType.FIELD; 7 | import static java.lang.annotation.ElementType.METHOD; 8 | import static java.lang.annotation.ElementType.PARAMETER; 9 | import static java.lang.annotation.ElementType.TYPE; 10 | 11 | import java.lang.annotation.Retention; 12 | import java.lang.annotation.RetentionPolicy; 13 | import java.lang.annotation.Target; 14 | 15 | /** 16 | * This annotation is added by the schema personalization file 17 | * 18 | * @author etienne-sf 19 | */ 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Target({ TYPE, FIELD, METHOD, PARAMETER }) 22 | public @interface MyAdditionalAnnotation { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/annotation/MyReplacementAnnotation.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.annotation; 5 | 6 | import static java.lang.annotation.ElementType.FIELD; 7 | import static java.lang.annotation.ElementType.METHOD; 8 | import static java.lang.annotation.ElementType.PARAMETER; 9 | import static java.lang.annotation.ElementType.TYPE; 10 | 11 | import java.lang.annotation.Retention; 12 | import java.lang.annotation.RetentionPolicy; 13 | import java.lang.annotation.Target; 14 | 15 | /** 16 | * This annotation is added by the schema personalization file 17 | * 18 | * @author etienne-sf 19 | */ 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Target({ TYPE, FIELD, METHOD, PARAMETER }) 22 | public @interface MyReplacementAnnotation { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/interfaces/AllInputTypes1.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface AllInputTypes1 { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/interfaces/AllInputTypes2.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface AllInputTypes2 { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/interfaces/AllInterfaces1.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface AllInterfaces1 { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/interfaces/AllInterfaces2.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface AllInterfaces2 { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/interfaces/AllTypes1.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface AllTypes1 { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/interfaces/AllTypes2.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface AllTypes2 { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/interfaces/AllUnions1.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface AllUnions1 { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/interfaces/AllUnions2.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface AllUnions2 { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/interfaces/AnyCharacterInterface.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface AnyCharacterInterface { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/interfaces/CharacterInterface.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface CharacterInterface { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/interfaces/DroidInputInterface.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface DroidInputInterface { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/interfaces/HumanInterface.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.interfaces; 2 | 3 | public interface HumanInterface { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/interfaces/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains interfaces that are used to test the schema personalization capability. These interfaces are 3 | * added to the generated classes, interfaces (...), as defined in the /src/main/graphql/schema_personalization.json 4 | * file 5 | */ 6 | package org.allGraphQLCases.interfaces; 7 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/config/CustomBeans.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.config; 2 | 3 | import java.util.Arrays; 4 | 5 | import org.springframework.boot.autoconfigure.graphql.GraphQlSourceBuilderCustomizer; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | @Configuration 10 | public class CustomBeans { 11 | 12 | @Bean 13 | public GraphQlSourceBuilderCustomizer sourceBuilderCustomizer() { 14 | return (builder) -> builder.instrumentation(Arrays.asList(new MyInstrumentation())); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/config/GraphQlException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.server.config; 5 | 6 | import java.util.List; 7 | 8 | import graphql.ErrorClassification; 9 | import graphql.ErrorType; 10 | import graphql.GraphQLError; 11 | import graphql.language.SourceLocation; 12 | 13 | /** 14 | * @author etienne-sf 15 | */ 16 | public class GraphQlException extends RuntimeException implements GraphQLError { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | public GraphQlException(String msg) { 21 | super(msg); 22 | } 23 | 24 | @Override 25 | public List getLocations() { 26 | return null; 27 | } 28 | 29 | @Override 30 | public ErrorClassification getErrorType() { 31 | return ErrorType.ExecutionAborted; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/config/MyInstrumentation.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.config; 2 | 3 | import java.util.Collections; 4 | import java.util.LinkedHashMap; 5 | import java.util.Map; 6 | import java.util.concurrent.CompletableFuture; 7 | 8 | import graphql.ExecutionResult; 9 | import graphql.ExecutionResultImpl; 10 | import graphql.execution.instrumentation.SimpleInstrumentation; 11 | import graphql.execution.instrumentation.parameters.InstrumentationExecutionParameters; 12 | 13 | /** 14 | * This class has been copied from 15 | * this 16 | * thread, based on graphql-java's TracingInstrumentation. 17 | * 18 | * @author Joe 19 | */ 20 | public class MyInstrumentation extends SimpleInstrumentation { 21 | 22 | public static class ExtensionValue { 23 | public String name; 24 | public String forname; 25 | } 26 | 27 | @Override 28 | public CompletableFuture instrumentExecutionResult(ExecutionResult executionResult, 29 | InstrumentationExecutionParameters parameters) { 30 | Map currentExt = executionResult.getExtensions(); 31 | Map newExtensionMap = new LinkedHashMap<>(); 32 | newExtensionMap.putAll(currentExt == null ? Collections.emptyMap() : currentExt); 33 | // 34 | // We add a specific object into the extensions map. It will be returned into the GraphQL responses. This allows 35 | // to check on client side that the extensions field is properly managed. 36 | ExtensionValue value = new ExtensionValue(); 37 | value.name = "The name"; 38 | value.forname = "The forname"; 39 | newExtensionMap.put("aValueToTestTheExtensionsField", value); 40 | 41 | return CompletableFuture.completedFuture( 42 | new ExecutionResultImpl(executionResult.getData(), executionResult.getErrors(), newExtensionMap)); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/config/MySubscriptionExceptionResolverAdapter.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.config; 2 | 3 | import org.springframework.graphql.execution.SubscriptionExceptionResolverAdapter; 4 | import org.springframework.stereotype.Component; 5 | 6 | import graphql.GraphQLError; 7 | 8 | /** 9 | * Implements the spring-graphql exception management, for Subscriptions 10 | * 11 | * @author etienne-sf 12 | */ 13 | @Component 14 | public class MySubscriptionExceptionResolverAdapter extends SubscriptionExceptionResolverAdapter { 15 | 16 | @Override 17 | protected GraphQLError resolveToSingleError(Throwable exception) { 18 | if (exception instanceof GraphQlException) { 19 | // As GraphQlException implements the GraphQLError interface, we can directly return it 20 | return (GraphQLError) exception; 21 | } else { 22 | return null; 23 | } 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/CharacterControllerOverridden.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.server.impl; 5 | 6 | import org.springframework.context.annotation.Primary; 7 | import org.springframework.graphql.data.method.annotation.Argument; 8 | import org.springframework.graphql.data.method.annotation.SchemaMapping; 9 | import org.springframework.stereotype.Controller; 10 | 11 | import graphql.schema.DataFetchingEnvironment; 12 | 13 | /** 14 | * @author gauthiereti 15 | * 16 | */ 17 | @Controller 18 | @Primary 19 | @SchemaMapping(typeName = "Character") 20 | public class CharacterControllerOverridden { 21 | 22 | @SchemaMapping(field = "name") 23 | public Object name(DataFetchingEnvironment dataFetchingEnvironment, 24 | org.allGraphQLCases.server.SIP_Character_SIS origin, @Argument("uppercase") java.lang.Boolean uppercase) { 25 | return ((uppercase != null && origin.getName() != null && uppercase) ? origin.getName().toUpperCase() 26 | : origin.getName()) + " (overridden)"; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateBatchMappingTypeImpl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import org.allGraphQLCases.server.DataFetchersDelegateBatchMappingType; 4 | import org.allGraphQLCases.server.STP_BatchMappingType_STS; 5 | import org.springframework.stereotype.Component; 6 | 7 | import graphql.schema.DataFetchingEnvironment; 8 | 9 | @Component 10 | public class DataFetchersDelegateBatchMappingTypeImpl implements DataFetchersDelegateBatchMappingType { 11 | 12 | @Override 13 | public Object friends(DataFetchingEnvironment dataFetchingEnvironment, STP_BatchMappingType_STS origin) { 14 | // TODO Auto-generated method stub 15 | return null; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateCharacterImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.server.impl; 5 | 6 | import java.util.List; 7 | import java.util.UUID; 8 | 9 | import javax.annotation.Resource; 10 | 11 | import org.allGraphQLCases.server.DataFetchersDelegateCharacter; 12 | import org.allGraphQLCases.server.SEP_Episode_SES; 13 | import org.allGraphQLCases.server.SIP_Character_SIS; 14 | import org.dataloader.BatchLoaderEnvironment; 15 | import org.springframework.stereotype.Component; 16 | 17 | import graphql.schema.DataFetchingEnvironment; 18 | 19 | /** 20 | * @author etienne-sf 21 | * 22 | */ 23 | @Component 24 | public class DataFetchersDelegateCharacterImpl implements DataFetchersDelegateCharacter { 25 | 26 | @Resource 27 | DataGenerator generator; 28 | 29 | @Override 30 | public List friends(DataFetchingEnvironment dataFetchingEnvironment, SIP_Character_SIS source) { 31 | return this.generator.generateInstanceList(SIP_Character_SIS.class, 4); 32 | } 33 | 34 | @Override 35 | public List appearsIn(DataFetchingEnvironment dataFetchingEnvironment, SIP_Character_SIS source) { 36 | return this.generator.generateInstanceList(SEP_Episode_SES.class, 2); 37 | } 38 | 39 | @Override 40 | public List batchLoader(List keys, BatchLoaderEnvironment environment) { 41 | return this.generator.generateInstanceList(SIP_Character_SIS.class, keys.size()); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateCommentedImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.server.impl; 5 | 6 | import java.util.List; 7 | 8 | import javax.annotation.Resource; 9 | 10 | import org.allGraphQLCases.server.SIP_Commented_SIS; 11 | import org.allGraphQLCases.server.DataFetchersDelegateCommented; 12 | import org.springframework.stereotype.Component; 13 | 14 | import graphql.schema.DataFetchingEnvironment; 15 | 16 | /** 17 | * @author etienne-sf 18 | * 19 | */ 20 | @Component 21 | public class DataFetchersDelegateCommentedImpl implements DataFetchersDelegateCommented { 22 | 23 | @Resource 24 | DataGenerator generator; 25 | 26 | @Override 27 | public List comments(DataFetchingEnvironment dataFetchingEnvironment, SIP_Commented_SIS source) { 28 | return generator.generateInstanceList(String.class, 10); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateFoo140Impl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import org.allGraphQLCases.server.STP_Bar140_STS; 4 | import org.allGraphQLCases.server.STP_Foo140_STS; 5 | import org.allGraphQLCases.server.DataFetchersDelegateFoo140; 6 | import org.springframework.stereotype.Component; 7 | 8 | import graphql.schema.DataFetchingEnvironment; 9 | 10 | @Component 11 | public class DataFetchersDelegateFoo140Impl implements DataFetchersDelegateFoo140 { 12 | 13 | @Override 14 | public STP_Bar140_STS bar(DataFetchingEnvironment dataFetchingEnvironment, STP_Foo140_STS origin) { 15 | return STP_Bar140_STS.builder().withName("Bar140's name for a Foo140").build(); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateI2Foo140Impl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import org.allGraphQLCases.server.STP_Bar140_STS; 4 | import org.allGraphQLCases.server.SIP_I2Bar140_SIS; 5 | import org.allGraphQLCases.server.SIP_I2Foo140_SIS; 6 | import org.allGraphQLCases.server.DataFetchersDelegateI2Foo140; 7 | import org.springframework.stereotype.Component; 8 | 9 | import graphql.schema.DataFetchingEnvironment; 10 | 11 | @Component 12 | public class DataFetchersDelegateI2Foo140Impl implements DataFetchersDelegateI2Foo140 { 13 | 14 | @Override 15 | public SIP_I2Bar140_SIS bar(DataFetchingEnvironment dataFetchingEnvironment, SIP_I2Foo140_SIS origin) { 16 | return STP_Bar140_STS.builder().withName("STP_Bar140_STS's name for an SIP_I2Bar140_SIS").build(); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateIBar12Impl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import java.util.List; 4 | import java.util.UUID; 5 | 6 | import org.allGraphQLCases.server.SIP_IBar12_SIS; 7 | import org.allGraphQLCases.server.DataFetchersDelegateIBar12; 8 | import org.dataloader.BatchLoaderEnvironment; 9 | import org.springframework.stereotype.Component; 10 | 11 | @Component 12 | public class DataFetchersDelegateIBar12Impl implements DataFetchersDelegateIBar12 { 13 | 14 | @Override 15 | public List batchLoader(List keys, BatchLoaderEnvironment environment) { 16 | return null; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateIBar1Impl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.UUID; 6 | 7 | import org.allGraphQLCases.server.SIP_IBar1_SIS; 8 | import org.allGraphQLCases.server.STP_TBar1_STS; 9 | import org.allGraphQLCases.server.DataFetchersDelegateIBar1; 10 | import org.dataloader.BatchLoaderEnvironment; 11 | import org.springframework.stereotype.Component; 12 | 13 | @Component 14 | public class DataFetchersDelegateIBar1Impl implements DataFetchersDelegateIBar1 { 15 | 16 | @Override 17 | public List batchLoader(List keys, BatchLoaderEnvironment environment) { 18 | List ret = new ArrayList<>(keys.size()); 19 | 20 | for (UUID key : keys) { 21 | ret.add(STP_TBar1_STS.builder().withId(key).build()); 22 | } 23 | 24 | return ret; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateIBar2Impl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import java.util.List; 4 | import java.util.UUID; 5 | 6 | import org.allGraphQLCases.server.SIP_IBar2_SIS; 7 | import org.allGraphQLCases.server.DataFetchersDelegateIBar2; 8 | import org.dataloader.BatchLoaderEnvironment; 9 | import org.springframework.stereotype.Component; 10 | 11 | @Component 12 | public class DataFetchersDelegateIBar2Impl implements DataFetchersDelegateIBar2 { 13 | 14 | @Override 15 | public List batchLoader(List keys, BatchLoaderEnvironment environment) { 16 | return null; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateIBar3Impl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import java.util.List; 4 | import java.util.UUID; 5 | 6 | import org.allGraphQLCases.server.SIP_IBar3_SIS; 7 | import org.allGraphQLCases.server.DataFetchersDelegateIBar3; 8 | import org.dataloader.BatchLoaderEnvironment; 9 | import org.springframework.stereotype.Component; 10 | 11 | @Component 12 | public class DataFetchersDelegateIBar3Impl implements DataFetchersDelegateIBar3 { 13 | 14 | @Override 15 | public List batchLoader(List keys, BatchLoaderEnvironment environment) { 16 | return null; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateIFoo140Impl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import org.allGraphQLCases.server.STP_Bar140_STS; 4 | import org.allGraphQLCases.server.SIP_IBar140_SIS; 5 | import org.allGraphQLCases.server.SIP_IFoo140_SIS; 6 | import org.allGraphQLCases.server.DataFetchersDelegateIFoo140; 7 | import org.springframework.stereotype.Component; 8 | 9 | import graphql.schema.DataFetchingEnvironment; 10 | 11 | @Component 12 | public class DataFetchersDelegateIFoo140Impl implements DataFetchersDelegateIFoo140 { 13 | 14 | @Override 15 | public SIP_IBar140_SIS bar(DataFetchingEnvironment dataFetchingEnvironment, SIP_IFoo140_SIS origin) { 16 | return STP_Bar140_STS.builder().withName("STP_Bar140_STS's name for an SIP_IBar140_SIS").build(); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateIFoo1Impl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import java.util.List; 4 | import java.util.UUID; 5 | import java.util.concurrent.CompletableFuture; 6 | 7 | import org.allGraphQLCases.server.DataFetchersDelegateIFoo1; 8 | import org.allGraphQLCases.server.SIP_IBar1_SIS; 9 | import org.allGraphQLCases.server.SIP_IFoo1_SIS; 10 | import org.dataloader.BatchLoaderEnvironment; 11 | import org.dataloader.DataLoader; 12 | import org.springframework.stereotype.Component; 13 | 14 | import graphql.schema.DataFetchingEnvironment; 15 | 16 | @Component 17 | public class DataFetchersDelegateIFoo1Impl implements DataFetchersDelegateIFoo1 { 18 | 19 | @Override 20 | public CompletableFuture bar(DataFetchingEnvironment dataFetchingEnvironment, 21 | DataLoader dataLoader, SIP_IFoo1_SIS origin) { 22 | // TODO Auto-generated method stub 23 | return null; 24 | } 25 | 26 | @Override 27 | public List batchLoader(List keys, BatchLoaderEnvironment environment) { 28 | // TODO Auto-generated method stub 29 | return null; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateIFoo2Impl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import java.util.List; 4 | import java.util.UUID; 5 | import java.util.concurrent.CompletableFuture; 6 | 7 | import org.allGraphQLCases.server.DataFetchersDelegateIFoo2; 8 | import org.allGraphQLCases.server.SIP_IBar2_SIS; 9 | import org.allGraphQLCases.server.SIP_IFoo2_SIS; 10 | import org.dataloader.BatchLoaderEnvironment; 11 | import org.dataloader.DataLoader; 12 | import org.springframework.stereotype.Component; 13 | 14 | import graphql.schema.DataFetchingEnvironment; 15 | 16 | @Component 17 | public class DataFetchersDelegateIFoo2Impl implements DataFetchersDelegateIFoo2 { 18 | 19 | @Override 20 | public CompletableFuture bar(DataFetchingEnvironment dataFetchingEnvironment, 21 | DataLoader dataLoader, SIP_IFoo2_SIS origin) { 22 | // TODO Auto-generated method stub 23 | return null; 24 | } 25 | 26 | @Override 27 | public List batchLoader(List keys, BatchLoaderEnvironment environment) { 28 | // TODO Auto-generated method stub 29 | return null; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateIFoo3Impl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import java.util.List; 4 | import java.util.UUID; 5 | import java.util.concurrent.CompletableFuture; 6 | 7 | import org.allGraphQLCases.server.DataFetchersDelegateIFoo3; 8 | import org.allGraphQLCases.server.SIP_IBar12_SIS; 9 | import org.allGraphQLCases.server.SIP_IFoo3_SIS; 10 | import org.dataloader.BatchLoaderEnvironment; 11 | import org.dataloader.DataLoader; 12 | import org.springframework.stereotype.Component; 13 | 14 | import graphql.schema.DataFetchingEnvironment; 15 | 16 | @Component 17 | public class DataFetchersDelegateIFoo3Impl implements DataFetchersDelegateIFoo3 { 18 | 19 | @Override 20 | public CompletableFuture bar(DataFetchingEnvironment dataFetchingEnvironment, 21 | DataLoader dataLoader, SIP_IFoo3_SIS origin) { 22 | // TODO Auto-generated method stub 23 | return null; 24 | } 25 | 26 | @Override 27 | public List batchLoader(List keys, BatchLoaderEnvironment environment) { 28 | // TODO Auto-generated method stub 29 | return null; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateIListImpl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import java.util.List; 4 | 5 | import org.allGraphQLCases.server.SIP_IFoo1_SIS; 6 | import org.allGraphQLCases.server.SIP_IList_SIS; 7 | import org.allGraphQLCases.server.DataFetchersDelegateIList; 8 | import org.springframework.stereotype.Component; 9 | 10 | import graphql.schema.DataFetchingEnvironment; 11 | 12 | @Component 13 | public class DataFetchersDelegateIListImpl implements DataFetchersDelegateIList { 14 | 15 | @Override 16 | public List list(DataFetchingEnvironment dataFetchingEnvironment, SIP_IList_SIS origin) { 17 | // TODO Auto-generated method stub 18 | return null; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateNodeImpl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import java.util.List; 4 | import java.util.UUID; 5 | 6 | import org.allGraphQLCases.server.SIP_Node_SIS; 7 | import org.allGraphQLCases.server.DataFetchersDelegateNode; 8 | import org.dataloader.BatchLoaderEnvironment; 9 | import org.springframework.stereotype.Component; 10 | 11 | @Component 12 | public class DataFetchersDelegateNodeImpl implements DataFetchersDelegateNode { 13 | 14 | @Override 15 | public List batchLoader(List keys, BatchLoaderEnvironment environment) { 16 | throw new RuntimeException("Not implemented yet"); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegatePetImpl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import org.allGraphQLCases.server.DataFetchersDelegatePet; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public class DataFetchersDelegatePetImpl implements DataFetchersDelegatePet { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateReservedJavaKeywordAsObjectField.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | public class DataFetchersDelegateReservedJavaKeywordAsObjectField { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateTBar12Impl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import java.util.List; 4 | import java.util.UUID; 5 | 6 | import org.allGraphQLCases.server.STP_TBar12_STS; 7 | import org.allGraphQLCases.server.DataFetchersDelegateTBar12; 8 | import org.dataloader.BatchLoaderEnvironment; 9 | import org.springframework.stereotype.Component; 10 | 11 | @Component 12 | public class DataFetchersDelegateTBar12Impl implements DataFetchersDelegateTBar12 { 13 | 14 | @Override 15 | public List batchLoader(List keys, BatchLoaderEnvironment environment) { 16 | return null; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateTBar1Impl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.UUID; 6 | 7 | import org.allGraphQLCases.server.STP_TBar1_STS; 8 | import org.allGraphQLCases.server.DataFetchersDelegateTBar1; 9 | import org.dataloader.BatchLoaderEnvironment; 10 | import org.springframework.stereotype.Component; 11 | 12 | @Component 13 | public class DataFetchersDelegateTBar1Impl implements DataFetchersDelegateTBar1 { 14 | 15 | @Override 16 | public List batchLoader(List keys, BatchLoaderEnvironment environment) { 17 | List ret = new ArrayList<>(keys.size()); 18 | 19 | for (UUID key : keys) { 20 | ret.add(STP_TBar1_STS.builder().withId(key).build()); 21 | } 22 | 23 | return ret; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateTBar2Impl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import java.util.List; 4 | import java.util.UUID; 5 | 6 | import org.allGraphQLCases.server.STP_TBar2_STS; 7 | import org.allGraphQLCases.server.DataFetchersDelegateTBar2; 8 | import org.dataloader.BatchLoaderEnvironment; 9 | import org.springframework.stereotype.Component; 10 | 11 | @Component 12 | public class DataFetchersDelegateTBar2Impl implements DataFetchersDelegateTBar2 { 13 | 14 | @Override 15 | public List batchLoader(List keys, BatchLoaderEnvironment environment) { 16 | return null; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateTFoo12Impl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import java.util.List; 4 | import java.util.UUID; 5 | import java.util.concurrent.CompletableFuture; 6 | 7 | import org.allGraphQLCases.server.DataFetchersDelegateTFoo12; 8 | import org.allGraphQLCases.server.STP_TBar12_STS; 9 | import org.allGraphQLCases.server.STP_TFoo12_STS; 10 | import org.dataloader.BatchLoaderEnvironment; 11 | import org.dataloader.DataLoader; 12 | import org.springframework.stereotype.Component; 13 | 14 | import graphql.schema.DataFetchingEnvironment; 15 | 16 | @Component 17 | public class DataFetchersDelegateTFoo12Impl implements DataFetchersDelegateTFoo12 { 18 | 19 | @Override 20 | public CompletableFuture bar(DataFetchingEnvironment dataFetchingEnvironment, 21 | DataLoader dataLoader, STP_TFoo12_STS origin) { 22 | // TODO Auto-generated method stub 23 | return null; 24 | } 25 | 26 | @Override 27 | public List batchLoader(List keys, BatchLoaderEnvironment environment) { 28 | // TODO Auto-generated method stub 29 | return null; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateTFoo1Impl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import java.util.List; 4 | import java.util.UUID; 5 | import java.util.concurrent.CompletableFuture; 6 | 7 | import org.allGraphQLCases.server.DataFetchersDelegateTFoo1; 8 | import org.allGraphQLCases.server.STP_TBar1_STS; 9 | import org.allGraphQLCases.server.STP_TFoo1_STS; 10 | import org.dataloader.BatchLoaderEnvironment; 11 | import org.dataloader.DataLoader; 12 | import org.springframework.stereotype.Component; 13 | 14 | import graphql.schema.DataFetchingEnvironment; 15 | 16 | @Component 17 | public class DataFetchersDelegateTFoo1Impl implements DataFetchersDelegateTFoo1 { 18 | 19 | @Override 20 | public CompletableFuture bar(DataFetchingEnvironment dataFetchingEnvironment, 21 | DataLoader dataLoader, STP_TFoo1_STS origin) { 22 | // TODO Auto-generated method stub 23 | return null; 24 | } 25 | 26 | @Override 27 | public List batchLoader(List keys, BatchLoaderEnvironment environment) { 28 | // TODO Auto-generated method stub 29 | return null; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateTFoo3Impl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import java.util.List; 4 | import java.util.UUID; 5 | import java.util.concurrent.CompletableFuture; 6 | 7 | import org.allGraphQLCases.server.DataFetchersDelegateTFoo3; 8 | import org.allGraphQLCases.server.STP_TBar12_STS; 9 | import org.allGraphQLCases.server.STP_TFoo3_STS; 10 | import org.dataloader.BatchLoaderEnvironment; 11 | import org.dataloader.DataLoader; 12 | import org.springframework.stereotype.Component; 13 | 14 | import graphql.schema.DataFetchingEnvironment; 15 | 16 | @Component 17 | public class DataFetchersDelegateTFoo3Impl implements DataFetchersDelegateTFoo3 { 18 | 19 | @Override 20 | public CompletableFuture bar(DataFetchingEnvironment dataFetchingEnvironment, 21 | DataLoader dataLoader, STP_TFoo3_STS origin) { 22 | // TODO Auto-generated method stub 23 | return null; 24 | } 25 | 26 | @Override 27 | public List batchLoader(List keys, BatchLoaderEnvironment environment) { 28 | // TODO Auto-generated method stub 29 | return null; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateTListImpl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import java.util.List; 4 | 5 | import org.allGraphQLCases.server.STP_TFoo1_STS; 6 | import org.allGraphQLCases.server.STP_TList_STS; 7 | import org.allGraphQLCases.server.DataFetchersDelegateTList; 8 | import org.springframework.stereotype.Component; 9 | 10 | import graphql.schema.DataFetchingEnvironment; 11 | 12 | @Component 13 | public class DataFetchersDelegateTListImpl implements DataFetchersDelegateTList { 14 | 15 | @Override 16 | public List list(DataFetchingEnvironment dataFetchingEnvironment, STP_TList_STS origin) { 17 | // TODO Auto-generated method stub 18 | return null; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateTypeWithJsonImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.server.impl; 5 | 6 | import java.util.Date; 7 | import java.util.List; 8 | 9 | import org.allGraphQLCases.server.DataFetchersDelegateTypeWithJson; 10 | import org.allGraphQLCases.server.SEP_Episode_SES; 11 | import org.allGraphQLCases.server.STP_TypeWithJson_STS; 12 | import org.springframework.stereotype.Component; 13 | 14 | import com.fasterxml.jackson.databind.node.ObjectNode; 15 | 16 | import graphql.schema.DataFetchingEnvironment; 17 | 18 | @Component 19 | public class DataFetchersDelegateTypeWithJsonImpl implements DataFetchersDelegateTypeWithJson { 20 | 21 | @Override 22 | public List jsons(DataFetchingEnvironment dataFetchingEnvironment, STP_TypeWithJson_STS origin) { 23 | List ret = origin.getJsons(); 24 | return ret; 25 | } 26 | 27 | /** Custom field data fetchers are available since release 2.5 */ 28 | @Override 29 | public String withArguments(DataFetchingEnvironment dataFetchingEnvironment, STP_TypeWithJson_STS origin, 30 | String test, Date date, Long _long, Boolean _boolean, SEP_Episode_SES _enum, ObjectNode json, 31 | List jsons) { 32 | return origin.getWithArguments() // 33 | + " (test=" + test// 34 | + ", date=" + date// 35 | + ", long=" + _long// 36 | + ", boolean=" + _boolean// 37 | + ", enum=" + _enum// 38 | + ", json=" + json// 39 | + ", jsons=" + jsons // 40 | + ")"; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateTypeWithObjectImpl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | import java.util.stream.Collectors; 6 | 7 | import org.allGraphQLCases.server.DataFetchersDelegateTypeWithObject; 8 | import org.allGraphQLCases.server.SEP_Episode_SES; 9 | import org.allGraphQLCases.server.STP_TypeWithObject_STS; 10 | import org.springframework.stereotype.Component; 11 | 12 | import graphql.schema.DataFetchingEnvironment; 13 | 14 | /** Custom field data fetchers are available since release 2.5 */ 15 | @Component 16 | public class DataFetchersDelegateTypeWithObjectImpl implements DataFetchersDelegateTypeWithObject { 17 | 18 | @Override 19 | public List objects(DataFetchingEnvironment dataFetchingEnvironment, STP_TypeWithObject_STS origin) { 20 | List ret = origin.getObjects().stream().collect(Collectors.toList()); 21 | return ret; 22 | } 23 | 24 | @Override 25 | public String withArguments(DataFetchingEnvironment dataFetchingEnvironment, STP_TypeWithObject_STS origin, 26 | String test, Date date, Long _long, Boolean _boolean, SEP_Episode_SES _enum, Object object, 27 | List objects) { 28 | return origin.getWithArguments() // 29 | + " (test=" + test// 30 | + ", date=" + date// 31 | + ", long=" + _long// 32 | + ", boolean=" + _boolean// 33 | + ", enum=" + _enum// 34 | + ", object=" + object// 35 | + ", objects=" + objects // 36 | + ")"; 37 | 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegateWithIDImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.server.impl; 5 | 6 | import java.util.List; 7 | import java.util.UUID; 8 | 9 | import javax.annotation.Resource; 10 | 11 | import org.allGraphQLCases.server.DataFetchersDelegateWithID; 12 | import org.allGraphQLCases.server.SIP_WithID_SIS; 13 | import org.dataloader.BatchLoaderEnvironment; 14 | import org.springframework.stereotype.Component; 15 | 16 | /** 17 | * @author etienne-sf 18 | * 19 | */ 20 | @Component 21 | public class DataFetchersDelegateWithIDImpl implements DataFetchersDelegateWithID { 22 | 23 | @Resource 24 | DataGenerator generator; 25 | 26 | @Override 27 | public List batchLoader(List keys, BatchLoaderEnvironment environment) { 28 | return generator.generateInstanceList(SIP_WithID_SIS.class, keys.size()); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/DataFetchersDelegatebreakImpl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import org.allGraphQLCases.server.DataFetchersDelegatebreak; 4 | import org.allGraphQLCases.server.SEP_extends_SES; 5 | import org.allGraphQLCases.server.STP_break_STS; 6 | import org.springframework.stereotype.Component; 7 | 8 | import graphql.schema.DataFetchingEnvironment; 9 | 10 | /** Custom field data fetchers are available since release 2.5 */ 11 | @Component 12 | public class DataFetchersDelegatebreakImpl implements DataFetchersDelegatebreak { 13 | 14 | /** Custom field data fetchers are available since release 2.5 */ 15 | @Override 16 | public SEP_extends_SES _case(DataFetchingEnvironment dataFetchingEnvironment, STP_break_STS origin, 17 | SEP_extends_SES test, String _if) { 18 | // A not-so-useful method 19 | return origin.getCase(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/MyQueryTypeControllerOverrided.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl; 2 | 3 | import org.springframework.graphql.data.method.annotation.SchemaMapping; 4 | import org.springframework.stereotype.Controller; 5 | 6 | import graphql.schema.DataFetchingEnvironment; 7 | 8 | /** 9 | * This class is used to check that the overriding of a Spring Controller actually works at runtime, so it must be 10 | * checked on client side. To do this, one of the returned strings is changed. 11 | */ 12 | @Controller 13 | @SchemaMapping(typeName = "MyQueryType") 14 | public class MyQueryTypeControllerOverrided { 15 | 16 | @SchemaMapping(field = "checkOverriddenController") 17 | public String checkOverriddenController(DataFetchingEnvironment dataFetchingEnvironment) { 18 | return "Welcome from the overridden controller"; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/relayConnection/DataFetchersDelegateCharacterConnectionImpl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl.relayConnection; 2 | 3 | import java.util.List; 4 | 5 | import org.allGraphQLCases.server.SIP_CharacterConnection_SIS; 6 | import org.allGraphQLCases.server.SIP_CharacterEdge_SIS; 7 | import org.allGraphQLCases.server.STP_PageInfo_STS; 8 | import org.allGraphQLCases.server.DataFetchersDelegateCharacterConnection; 9 | import org.springframework.stereotype.Component; 10 | 11 | import graphql.schema.DataFetchingEnvironment; 12 | 13 | @Component 14 | public class DataFetchersDelegateCharacterConnectionImpl implements DataFetchersDelegateCharacterConnection { 15 | 16 | @Override 17 | public List edges(DataFetchingEnvironment dataFetchingEnvironment, SIP_CharacterConnection_SIS origin) { 18 | return origin.getEdges(); 19 | } 20 | 21 | @Override 22 | public STP_PageInfo_STS pageInfo(DataFetchingEnvironment dataFetchingEnvironment, SIP_CharacterConnection_SIS origin) { 23 | return origin.getPageInfo(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/relayConnection/DataFetchersDelegateCharacterEdgeImpl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl.relayConnection; 2 | 3 | import java.util.UUID; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | import org.allGraphQLCases.server.DataFetchersDelegateCharacterEdge; 7 | import org.allGraphQLCases.server.SIP_CharacterEdge_SIS; 8 | import org.allGraphQLCases.server.SIP_Character_SIS; 9 | import org.dataloader.DataLoader; 10 | import org.springframework.stereotype.Component; 11 | 12 | import graphql.schema.DataFetchingEnvironment; 13 | 14 | @Component 15 | public class DataFetchersDelegateCharacterEdgeImpl implements DataFetchersDelegateCharacterEdge { 16 | 17 | @Override 18 | public CompletableFuture node(DataFetchingEnvironment dataFetchingEnvironment, 19 | DataLoader dataLoader, SIP_CharacterEdge_SIS origin) { 20 | return CompletableFuture.completedFuture(origin.getNode()); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/relayConnection/DataFetchersDelegateHumanConnectionImpl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl.relayConnection; 2 | 3 | import java.util.List; 4 | 5 | import org.allGraphQLCases.server.STP_HumanConnection_STS; 6 | import org.allGraphQLCases.server.STP_HumanEdge_STS; 7 | import org.allGraphQLCases.server.STP_PageInfo_STS; 8 | import org.allGraphQLCases.server.DataFetchersDelegateHumanConnection; 9 | import org.springframework.stereotype.Component; 10 | 11 | import graphql.schema.DataFetchingEnvironment; 12 | 13 | @Component 14 | public class DataFetchersDelegateHumanConnectionImpl implements DataFetchersDelegateHumanConnection { 15 | 16 | @Override 17 | public List edges(DataFetchingEnvironment dataFetchingEnvironment, STP_HumanConnection_STS origin) { 18 | return origin.getEdges(); 19 | } 20 | 21 | @Override 22 | public STP_PageInfo_STS pageInfo(DataFetchingEnvironment dataFetchingEnvironment, STP_HumanConnection_STS origin) { 23 | return origin.getPageInfo(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/relayConnection/DataFetchersDelegateHumanEdgeImpl.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.impl.relayConnection; 2 | 3 | import java.util.UUID; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | import org.allGraphQLCases.server.DataFetchersDelegateHumanEdge; 7 | import org.allGraphQLCases.server.STP_HumanEdge_STS; 8 | import org.allGraphQLCases.server.STP_Human_STS; 9 | import org.dataloader.DataLoader; 10 | import org.springframework.stereotype.Component; 11 | 12 | import graphql.schema.DataFetchingEnvironment; 13 | 14 | @Component 15 | public class DataFetchersDelegateHumanEdgeImpl implements DataFetchersDelegateHumanEdge { 16 | 17 | @Override 18 | public CompletableFuture node(DataFetchingEnvironment dataFetchingEnvironment, 19 | DataLoader dataLoader, STP_HumanEdge_STS origin) { 20 | // This works with this simple sample. For real case, it would be better to use the CompletableFuture, to 21 | // execute the request asynchronously 22 | return CompletableFuture.completedFuture(origin.getNode()); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/impl/relayConnection/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains all the Data Fetcher that are specific to the relay connection capability.
3 | * They are necessary only if the addRelayConnections plugin parameter is set to true. 4 | * 5 | * @author etienne-sf 6 | */ 7 | package org.allGraphQLCases.server.impl.relayConnection; -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/oauth2/HelloWorld.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.allGraphQLCases.server.oauth2; 5 | 6 | import java.security.Principal; 7 | 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | /** 12 | * This URI is used in maven build, to check that the server is properly started. 13 | * 14 | * @author etienne-sf 15 | */ 16 | @RestController 17 | public class HelloWorld { 18 | 19 | @GetMapping("/helloworld.html") 20 | public String get(final Principal principal) { 21 | return "Hello World, I'm started!"; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/java/org/allGraphQLCases/server/oauth2/WebSecurityConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.allGraphQLCases.server.oauth2; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 5 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 6 | import org.springframework.security.web.SecurityFilterChain; 7 | 8 | /** 9 | * 10 | * @author etienne-sf 11 | * @see https://docs.spring.io/spring-security/site/docs/5.4.2/reference/html5/#servlet-authorization-filtersecurityinterceptor 12 | */ 13 | @EnableWebSecurity 14 | public class WebSecurityConfiguration { 15 | 16 | @Bean 17 | SecurityFilterChain configure(HttpSecurity http) throws Exception { 18 | http// 19 | // Disabling CORS and CSRF makes POST on the graphql URL work properly. Double-check that before 20 | // entering in production 21 | .cors().and().csrf().disable()// 22 | .authorizeRequests().antMatchers("/my/updated/graphql/path").authenticated() 23 | // .hasAuthority("ROLE_CLIENT")// 24 | .and()// 25 | .oauth2ResourceServer().jwt(); 26 | return http.build(); 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | # Changing the port for the GraphQL server 2 | server: 3 | port: 8180 4 | 5 | security: 6 | enable: 7 | csrf: false # This should probably not be done in production 8 | 9 | spring: 10 | graphql: 11 | # Changing the server path 12 | path: /my/updated/graphql/path 13 | 14 | # Both activating the web socket support and overriding the default path 15 | websocket: 16 | path: /my/updated/graphql/path 17 | 18 | # Enabling graphiql (from spring-graphql) 19 | graphiql: 20 | enabled: true 21 | jackson: 22 | serialization: 23 | INDENT_OUTPUT: true 24 | security: 25 | oauth2: 26 | resourceserver: 27 | jwt: 28 | issuer-uri: http://localhost:8181 29 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/resources/logback-local.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 10 | 11 | 12 | 13 | target/server.log 14 | 15 | %date %level [%thread] %logger{10} [%file:%line] %msg%n 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 7 | 8 | 9 | 10 | target/server.log 11 | 12 | %date %level [%thread] %logger{10} [%file:%line] %msg%n 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /graphql-gradle-plugin-samples-allGraphQLCases-server/src/site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | org.apache.maven.skins 6 | maven-fluido-skin 7 | 2.0.0-M5 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /graphql-gradle-plugin/gradle.properties: -------------------------------------------------------------------------------- 1 | # Current project group and version 2 | group = com.graphql-java-generator 3 | version = 2.9 4 | 5 | // This configuration block declares local project variable, with all versions for common dependencies 6 | commonsLang3Version = 3.12.0 7 | dozerVersion = 6.5.2 8 | jacksonDatabindVersion = 2.13.5 9 | springBootVersion = 2.7.18 10 | springFrameworkVersion = 5.3.31 11 | -------------------------------------------------------------------------------- /graphql-gradle-plugin/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphql-java-generator/graphql-gradle-plugin-project/a6fe37c08ae032c52784d38b4a121050b71f7041/graphql-gradle-plugin/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /graphql-gradle-plugin/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /graphql-gradle-plugin/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'graphql-gradle-plugin' 2 | -------------------------------------------------------------------------------- /graphql-gradle-plugin/src/main/java/com/graphql_java_generator/gradleplugin/GenerateClientCodeExtension.java: -------------------------------------------------------------------------------- 1 | package com.graphql_java_generator.gradleplugin; 2 | 3 | import org.gradle.api.file.ProjectLayout; 4 | 5 | import com.graphql_java_generator.plugin.conf.GenerateClientCodeConfiguration; 6 | import com.graphql_java_generator.plugin.conf.GraphQLConfiguration; 7 | import com.graphql_java_generator.plugin.conf.PluginMode; 8 | 9 | public class GenerateClientCodeExtension extends GenerateCodeCommonExtension 10 | implements GenerateClientCodeConfiguration { 11 | 12 | private boolean generateDeprecatedRequestResponse = GraphQLConfiguration.DEFAULT_GENERATE_DEPRECATED_REQUEST_RESPONSE 13 | .equals("true"); 14 | 15 | public GenerateClientCodeExtension(ProjectLayout projectLayout) { 16 | super(projectLayout); 17 | } 18 | 19 | @Override 20 | public boolean isGenerateDeprecatedRequestResponse() { 21 | return generateDeprecatedRequestResponse; 22 | } 23 | 24 | public void setGenerateDeprecatedRequestResponse(boolean generateDeprecatedRequestResponse) { 25 | this.generateDeprecatedRequestResponse = generateDeprecatedRequestResponse; 26 | // This task as being configured. So we'll mark compileJava and processResources as depending on it 27 | setInitialized(true); 28 | } 29 | 30 | /** The mode is forced to {@link PluginMode#client} */ 31 | @Override 32 | public PluginMode getMode() { 33 | return PluginMode.client; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /graphql-gradle-plugin/src/main/java/com/graphql_java_generator/gradleplugin/GenerateClientCodeSpringConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.graphql_java_generator.gradleplugin; 5 | 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.ComponentScan; 8 | import org.springframework.context.annotation.ComponentScan.Filter; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.context.annotation.FilterType; 11 | 12 | import com.graphql_java_generator.plugin.DocumentParser; 13 | import com.graphql_java_generator.util.GraphqlUtils; 14 | 15 | /** 16 | * @author EtienneSF 17 | */ 18 | @Configuration 19 | @ComponentScan(basePackageClasses = { DocumentParser.class, GraphqlUtils.class }, // 20 | excludeFilters = { @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateGraphQLSchema.*"), 21 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GeneratePojo.*"), 22 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateServerCode.*"), 23 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GraphQL.*") }) 24 | public class GenerateClientCodeSpringConfiguration { 25 | 26 | /** 27 | * The current GraphQL extension, that contains the plugin configuration. It is set by the 28 | * {@link GenerateServerCodeTask} task, before it starts the Spring context 29 | */ 30 | static GenerateClientCodeTask generateClientCodeConf = null; 31 | 32 | @Bean 33 | GenerateClientCodeTask generateClientCodeConf() { 34 | return generateClientCodeConf; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /graphql-gradle-plugin/src/main/java/com/graphql_java_generator/gradleplugin/GenerateGraphQLSchemaSpringConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.graphql_java_generator.gradleplugin; 5 | 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.ComponentScan; 8 | import org.springframework.context.annotation.ComponentScan.Filter; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.context.annotation.FilterType; 11 | 12 | import com.graphql_java_generator.plugin.DocumentParser; 13 | import com.graphql_java_generator.util.GraphqlUtils; 14 | 15 | /** 16 | * @author EtienneSF 17 | */ 18 | @Configuration 19 | @ComponentScan(basePackageClasses = { DocumentParser.class, GraphqlUtils.class }, // 20 | excludeFilters = { @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateClientCode.*"), 21 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateCode.*"), 22 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GeneratePojo.*"), 23 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateServerCode.*"), 24 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GraphQL.*") }) 25 | public class GenerateGraphQLSchemaSpringConfiguration { 26 | 27 | /** 28 | * The current GraphQL extension, that contains the plugin configuration. It is set by the 29 | * {@link GenerateGraphQLSchemaTask} task, before it starts the Spring context 30 | */ 31 | static GenerateGraphQLSchemaTask generateGraphQLSchemaConf = null; 32 | 33 | @Bean 34 | GenerateGraphQLSchemaTask generateGraphQLSchemaConf() { 35 | return generateGraphQLSchemaConf; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /graphql-gradle-plugin/src/main/java/com/graphql_java_generator/gradleplugin/GeneratePojoExtension.java: -------------------------------------------------------------------------------- 1 | package com.graphql_java_generator.gradleplugin; 2 | 3 | import java.io.Serializable; 4 | 5 | import org.gradle.api.file.ProjectLayout; 6 | 7 | import com.graphql_java_generator.plugin.conf.GeneratePojoConfiguration; 8 | import com.graphql_java_generator.plugin.conf.PluginMode; 9 | 10 | /** 11 | * Parameters for the GraphQL Gradle plugin. 12 | * 13 | * @author EtienneSF 14 | * 15 | */ 16 | public class GeneratePojoExtension extends GraphQLExtension implements GeneratePojoConfiguration, Serializable { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | /** 21 | *

22 | * The Jackson annotations are necessary to properly deserialize 23 | * the json, that is incoming from the GraphQL Server. Setting this property to false allows to not generate them. 24 | *

25 | *

26 | * If this property is set to true, the Jackson annotations are added in the generated GraphQL objects. The 27 | * Jackson dependencies must then be added to the target project, 28 | * so that the project compiles. 29 | *

30 | *

31 | * The default value is: 32 | *

33 | *
    34 | *
  • true when in client mode.
  • 35 | *
  • false when in server mode.
  • 36 | *
37 | */ 38 | Boolean generateJacksonAnnotations = null; 39 | 40 | public GeneratePojoExtension(ProjectLayout projectLayout) { 41 | super(projectLayout, null); 42 | } 43 | 44 | @Override 45 | public boolean isGenerateJacksonAnnotations() { 46 | if (generateJacksonAnnotations != null) 47 | return generateJacksonAnnotations; 48 | else 49 | return getMode().equals(PluginMode.client); 50 | } 51 | 52 | public Boolean isGenerateJacksonAnnotations_Raw() { 53 | return generateJacksonAnnotations; 54 | } 55 | 56 | public void setGenerateJacksonAnnotations(boolean generateJacksonAnnotations) { 57 | this.generateJacksonAnnotations = generateJacksonAnnotations; 58 | // This task as being configured. So we'll mark compileJava and processResources as depending on it 59 | setInitialized(true); 60 | } 61 | } -------------------------------------------------------------------------------- /graphql-gradle-plugin/src/main/java/com/graphql_java_generator/gradleplugin/GeneratePojoSpringConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.graphql_java_generator.gradleplugin; 5 | 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.ComponentScan; 8 | import org.springframework.context.annotation.ComponentScan.Filter; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.context.annotation.FilterType; 11 | 12 | import com.graphql_java_generator.plugin.DocumentParser; 13 | import com.graphql_java_generator.util.GraphqlUtils; 14 | 15 | /** 16 | * @author EtienneSF 17 | */ 18 | @Configuration 19 | @ComponentScan(basePackageClasses = { DocumentParser.class, GraphqlUtils.class }, // 20 | excludeFilters = { @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateGraphQLSchema.*"), 21 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateClientCode.*"), 22 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateGraphQLSchema.*"), 23 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateServerCode.*") }) 24 | public class GeneratePojoSpringConfiguration { 25 | 26 | /** 27 | * The current GraphQL extension, that contains the plugin configuration. It is set by the 28 | * {@link GraphQLGenerateCodeTask} task, before it starts the Spring context 29 | */ 30 | static GeneratePojoTask graphqlPojoConf = null; 31 | 32 | @Bean 33 | GeneratePojoTask graphqlPojoConf() { 34 | return graphqlPojoConf; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /graphql-gradle-plugin/src/main/java/com/graphql_java_generator/gradleplugin/GenerateServerCodeSpringConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.graphql_java_generator.gradleplugin; 5 | 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.ComponentScan; 8 | import org.springframework.context.annotation.ComponentScan.Filter; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.context.annotation.FilterType; 11 | 12 | import com.graphql_java_generator.plugin.DocumentParser; 13 | import com.graphql_java_generator.util.GraphqlUtils; 14 | 15 | /** 16 | * @author EtienneSF 17 | */ 18 | @Configuration 19 | @ComponentScan(basePackageClasses = { DocumentParser.class, GraphqlUtils.class }, // 20 | excludeFilters = { @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateClientCode.*"), 21 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateGraphQLSchema.*"), 22 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GeneratePojo.*"), 23 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GraphQL.*") }) 24 | public class GenerateServerCodeSpringConfiguration { 25 | 26 | /** 27 | * The current GraphQL extension, that contains the plugin configuration. It is set by the 28 | * {@link GenerateServerCodeTask} task, before it starts the Spring context 29 | */ 30 | static GenerateServerCodeTask generateServerCodeConf = null; 31 | 32 | @Bean 33 | GenerateServerCodeTask generateServerCodeConf() { 34 | return generateServerCodeConf; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /graphql-gradle-plugin/src/main/java/com/graphql_java_generator/gradleplugin/GraphQLGenerateCodeSpringConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.graphql_java_generator.gradleplugin; 5 | 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.ComponentScan; 8 | import org.springframework.context.annotation.ComponentScan.Filter; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.context.annotation.FilterType; 11 | 12 | import com.graphql_java_generator.plugin.DocumentParser; 13 | import com.graphql_java_generator.util.GraphqlUtils; 14 | 15 | /** 16 | * @author EtienneSF 17 | */ 18 | @Configuration 19 | // @Import({ JacksonAutoConfiguration.class }) 20 | @ComponentScan(basePackageClasses = { DocumentParser.class, GraphqlUtils.class }, // 21 | excludeFilters = { @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateClientCode.*"), 22 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateGraphQLSchema.*"), 23 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GeneratePojo.*"), 24 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateServerCode.*") }) 25 | public class GraphQLGenerateCodeSpringConfiguration { 26 | 27 | /** 28 | * The current GraphQL extension, that contains the plugin configuration. It is set by the 29 | * {@link GraphQLGenerateCodeTask} task, before it starts the Spring context 30 | */ 31 | static GraphQLGenerateCodeTask graphqlGenerateCodeConf = null; 32 | 33 | @Bean 34 | GraphQLGenerateCodeTask graphqlGenerateCodeConf() { 35 | return graphqlGenerateCodeConf; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /graphql-gradle-plugin/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | plugin.version = ${projectVersion} 2 | graphqlMavenPluginLogic.version = ${graphqlMavenPluginLogicVersion} 3 | -------------------------------------------------------------------------------- /graphql-gradle-plugin/src/test/java/com/graphql_java_generator/gradleplugin/GraphQLPluginTest.java: -------------------------------------------------------------------------------- 1 | package com.graphql_java_generator.gradleplugin; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertNotEquals; 4 | import static org.junit.jupiter.api.Assertions.assertNotNull; 5 | 6 | import org.junit.jupiter.api.BeforeEach; 7 | import org.junit.jupiter.api.Test; 8 | 9 | public class GraphQLPluginTest { 10 | 11 | GraphQLPlugin graphQLPlugin; 12 | 13 | @BeforeEach 14 | void setup() { 15 | graphQLPlugin = new GraphQLPlugin(); 16 | } 17 | 18 | @Test 19 | void test_getVersion() { 20 | String version = graphQLPlugin.getVersion(); 21 | assertNotNull(version); 22 | assertNotEquals("${projectVersion}", version, "version is: '" + version + "'"); 23 | } 24 | 25 | @Test 26 | void test_getDependenciesVersion() { 27 | String version = graphQLPlugin.getDependenciesVersion(); 28 | assertNotNull(version); 29 | assertNotEquals("${graphqlMavenPluginLogicVersion}", version, "version is: '" + version + "'"); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /graphql-gradle-plugin/src/test/resources/functionalTest/basic.graphqls: -------------------------------------------------------------------------------- 1 | type Query { 2 | getMsg: Message! 3 | } 4 | 5 | type Message { 6 | msg: String! 7 | } -------------------------------------------------------------------------------- /graphql-gradle-plugin/src/test/resources/functionalTest/build_generateServerCode.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | id 'com.graphql-java-generator.graphql-gradle-plugin' 4 | id 'org.springframework.boot' version "${springBootVersion}" 5 | id 'io.spring.dependency-management' version "${springDependencyManagementPluginVersion}" 6 | } 7 | 8 | repositories { 9 | // The plugin depends on the graphql-maven-plugin plugin logic module, which is in mavenCentral (for releases), and in mavenLocal 10 | // when working on the plugin development. 11 | mavenCentral() 12 | mavenLocal() // Only if you work on the plugin development 13 | } 14 | 15 | dependencies { 16 | // The graphql-java-client-dependencies module agregates all dependencies for the generated code 17 | implementation "com.graphql-java-generator:graphql-java-server-runtime:${project.version}" 18 | 19 | // Then, the dependencies that are specific to this project 20 | implementation "org.springframework.boot:spring-boot-starter-websocket" // Mandatory to activate the web sockets (mandatory for subscription) 21 | implementation "org.springframework.boot:spring-boot-starter-security" 22 | implementation "org.springframework.boot:spring-boot-starter-oauth2-resource-server" 23 | 24 | // This project uses some custom scalars from the graphql-java-extended-scalars module 25 | implementation "com.graphql-java:graphql-java-extended-scalars:${graphqlJavaExtendedScalarsVersion}" 26 | 27 | implementation "com.github.dozermapper:dozer-core:${dozerVersion}" 28 | } 29 | 30 | generateServerCode { 31 | packaging = 'war' 32 | } 33 | 34 | tasks.register('generateServerCodeRegister', com.graphql_java_generator.gradleplugin.GenerateServerCodeTask) { 35 | targetResourceFolder = '/build/generated-resources/generateServerCodeRegister' 36 | targetSourceFolder = '/build/generated-sources/generateServerCodeRegister' 37 | packaging = 'war' 38 | } 39 | -------------------------------------------------------------------------------- /graphql-gradle-plugin/src/test/resources/functionalTest/build_registerTask.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java-library' 3 | id 'com.graphql-java-generator.graphql-gradle-plugin' 4 | id 'org.springframework.boot' version "${springBootVersion}" 5 | id 'io.spring.dependency-management' version "${springDependencyManagementPluginVersion}" 6 | } 7 | 8 | repositories { 9 | mavenCentral() 10 | // The plugin depends on the graphql-maven-plugin, whose snapshot versions are on the local maven repository. 11 | // So, for development reason, we need to access to the local maven repository. It's useless for standard use of the plugin 12 | mavenLocal() 13 | } 14 | 15 | dependencies { 16 | // And the Jackson annotations 17 | implementation "com.fasterxml.jackson.core:jackson-databind" 18 | // This project uses some custom scalars from the graphql-java-extended-scalars module 19 | implementation "com.graphql-java:graphql-java-extended-scalars:${graphqlJavaExtendedScalarsVersion}" 20 | } 21 | 22 | tasks.register('generateClientPojo', com.graphql_java_generator.gradleplugin.GeneratePojoTask) { 23 | packageName = "org.functionalTest" 24 | generateJacksonAnnotations = false 25 | mode = 'client' 26 | packaging = 'war' 27 | } -------------------------------------------------------------------------------- /graphql-gradle-plugin/src/test/resources/functionalTest/build_usingExtension.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java-library' 3 | id 'com.graphql-java-generator.graphql-gradle-plugin' 4 | id 'org.springframework.boot' version "${springBootVersion}" 5 | id 'io.spring.dependency-management' version "${springDependencyManagementPluginVersion}" 6 | } 7 | 8 | repositories { 9 | mavenCentral() 10 | // The plugin depends on the graphql-maven-plugin, whose snapshot versions are on the local maven repository. 11 | // So, for development reason, we need to access to the local maven repository. It's useless for standard use of the plugin 12 | mavenLocal() 13 | } 14 | 15 | dependencies { 16 | // And the Jackson annotations 17 | implementation "com.fasterxml.jackson.core:jackson-databind" 18 | // This project uses some custom scalars from the graphql-java-extended-scalars module 19 | implementation "com.graphql-java:graphql-java-extended-scalars:${graphqlJavaExtendedScalarsVersion}" 20 | } 21 | 22 | generatePojo { 23 | packageName = "org.functionalTest" 24 | generateJacksonAnnotations = false 25 | mode = 'client' 26 | } -------------------------------------------------------------------------------- /graphql-gradle-plugin/src/test/resources/functionalTest/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | maven { url "https://plugins.gradle.org/m2/" } 4 | gradlePluginPortal() 5 | } 6 | } 7 | 8 | rootProject.name = 'functionalTest' 9 | -------------------------------------------------------------------------------- /graphql-gradle-plugin/src/test/resources/log4j2-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /graphql-gradle-plugin3/gradle.properties: -------------------------------------------------------------------------------- 1 | # Current project group and version 2 | group = com.graphql-java-generator 3 | version = 2.9 4 | 5 | // This configuration block declares local project variable, with all versions for common dependencies 6 | commonsLang3Version = 3.12.0 7 | dozerVersion = 6.5.2 8 | jacksonDatabindVersion = 2.13.5 9 | springBootVersion = 3.2.1 10 | springFrameworkVersion = 6.1.2 11 | -------------------------------------------------------------------------------- /graphql-gradle-plugin3/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphql-java-generator/graphql-gradle-plugin-project/a6fe37c08ae032c52784d38b4a121050b71f7041/graphql-gradle-plugin3/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /graphql-gradle-plugin3/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /graphql-gradle-plugin3/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'graphql-gradle-plugin3' 2 | -------------------------------------------------------------------------------- /graphql-gradle-plugin3/src/main/java/com/graphql_java_generator/gradleplugin/GenerateClientCodeExtension.java: -------------------------------------------------------------------------------- 1 | package com.graphql_java_generator.gradleplugin; 2 | 3 | import org.gradle.api.file.ProjectLayout; 4 | 5 | import com.graphql_java_generator.plugin.conf.GenerateClientCodeConfiguration; 6 | import com.graphql_java_generator.plugin.conf.GraphQLConfiguration; 7 | import com.graphql_java_generator.plugin.conf.PluginMode; 8 | 9 | public class GenerateClientCodeExtension extends GenerateCodeCommonExtension 10 | implements GenerateClientCodeConfiguration { 11 | 12 | private boolean generateDeprecatedRequestResponse = GraphQLConfiguration.DEFAULT_GENERATE_DEPRECATED_REQUEST_RESPONSE 13 | .equals("true"); 14 | 15 | public GenerateClientCodeExtension(ProjectLayout projectLayout) { 16 | super(projectLayout); 17 | } 18 | 19 | @Override 20 | public boolean isGenerateDeprecatedRequestResponse() { 21 | return generateDeprecatedRequestResponse; 22 | } 23 | 24 | public void setGenerateDeprecatedRequestResponse(boolean generateDeprecatedRequestResponse) { 25 | this.generateDeprecatedRequestResponse = generateDeprecatedRequestResponse; 26 | // This task as being configured. So we'll mark compileJava and processResources as depending on it 27 | setInitialized(true); 28 | } 29 | 30 | /** The mode is forced to {@link PluginMode#client} */ 31 | @Override 32 | public PluginMode getMode() { 33 | return PluginMode.client; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /graphql-gradle-plugin3/src/main/java/com/graphql_java_generator/gradleplugin/GenerateClientCodeSpringConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.graphql_java_generator.gradleplugin; 5 | 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.ComponentScan; 8 | import org.springframework.context.annotation.ComponentScan.Filter; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.context.annotation.FilterType; 11 | 12 | import com.graphql_java_generator.plugin.DocumentParser; 13 | import com.graphql_java_generator.util.GraphqlUtils; 14 | 15 | /** 16 | * @author EtienneSF 17 | */ 18 | @Configuration 19 | @ComponentScan(basePackageClasses = { DocumentParser.class, GraphqlUtils.class }, // 20 | excludeFilters = { @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateGraphQLSchema.*"), 21 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GeneratePojo.*"), 22 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateServerCode.*"), 23 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GraphQL.*") }) 24 | public class GenerateClientCodeSpringConfiguration { 25 | 26 | /** 27 | * The current GraphQL extension, that contains the plugin configuration. It is set by the 28 | * {@link GenerateServerCodeTask} task, before it starts the Spring context 29 | */ 30 | static GenerateClientCodeTask generateClientCodeConf = null; 31 | 32 | @Bean 33 | GenerateClientCodeTask generateClientCodeConf() { 34 | return generateClientCodeConf; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /graphql-gradle-plugin3/src/main/java/com/graphql_java_generator/gradleplugin/GenerateGraphQLSchemaSpringConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.graphql_java_generator.gradleplugin; 5 | 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.ComponentScan; 8 | import org.springframework.context.annotation.ComponentScan.Filter; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.context.annotation.FilterType; 11 | 12 | import com.graphql_java_generator.plugin.DocumentParser; 13 | import com.graphql_java_generator.util.GraphqlUtils; 14 | 15 | /** 16 | * @author EtienneSF 17 | */ 18 | @Configuration 19 | @ComponentScan(basePackageClasses = { DocumentParser.class, GraphqlUtils.class }, // 20 | excludeFilters = { @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateClientCode.*"), 21 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateCode.*"), 22 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GeneratePojo.*"), 23 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateServerCode.*"), 24 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GraphQL.*") }) 25 | public class GenerateGraphQLSchemaSpringConfiguration { 26 | 27 | /** 28 | * The current GraphQL extension, that contains the plugin configuration. It is set by the 29 | * {@link GenerateGraphQLSchemaTask} task, before it starts the Spring context 30 | */ 31 | static GenerateGraphQLSchemaTask generateGraphQLSchemaConf = null; 32 | 33 | @Bean 34 | GenerateGraphQLSchemaTask generateGraphQLSchemaConf() { 35 | return generateGraphQLSchemaConf; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /graphql-gradle-plugin3/src/main/java/com/graphql_java_generator/gradleplugin/GeneratePojoExtension.java: -------------------------------------------------------------------------------- 1 | package com.graphql_java_generator.gradleplugin; 2 | 3 | import java.io.Serializable; 4 | 5 | import org.gradle.api.file.ProjectLayout; 6 | 7 | import com.graphql_java_generator.plugin.conf.GeneratePojoConfiguration; 8 | import com.graphql_java_generator.plugin.conf.PluginMode; 9 | 10 | /** 11 | * Parameters for the GraphQL Gradle plugin. 12 | * 13 | * @author EtienneSF 14 | * 15 | */ 16 | public class GeneratePojoExtension extends GraphQLExtension implements GeneratePojoConfiguration, Serializable { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | /** 21 | *

22 | * The Jackson annotations are necessary to properly deserialize 23 | * the json, that is incoming from the GraphQL Server. Setting this property to false allows to not generate them. 24 | *

25 | *

26 | * If this property is set to true, the Jackson annotations are added in the generated GraphQL objects. The 27 | * Jackson dependencies must then be added to the target project, 28 | * so that the project compiles. 29 | *

30 | *

31 | * The default value is: 32 | *

33 | *
    34 | *
  • true when in client mode.
  • 35 | *
  • false when in server mode.
  • 36 | *
37 | */ 38 | Boolean generateJacksonAnnotations = null; 39 | 40 | public GeneratePojoExtension(ProjectLayout projectLayout) { 41 | super(projectLayout, null); 42 | } 43 | 44 | @Override 45 | public boolean isGenerateJacksonAnnotations() { 46 | if (generateJacksonAnnotations != null) 47 | return generateJacksonAnnotations; 48 | else 49 | return getMode().equals(PluginMode.client); 50 | } 51 | 52 | public Boolean isGenerateJacksonAnnotations_Raw() { 53 | return generateJacksonAnnotations; 54 | } 55 | 56 | public void setGenerateJacksonAnnotations(boolean generateJacksonAnnotations) { 57 | this.generateJacksonAnnotations = generateJacksonAnnotations; 58 | // This task as being configured. So we'll mark compileJava and processResources as depending on it 59 | setInitialized(true); 60 | } 61 | } -------------------------------------------------------------------------------- /graphql-gradle-plugin3/src/main/java/com/graphql_java_generator/gradleplugin/GeneratePojoSpringConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.graphql_java_generator.gradleplugin; 5 | 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.ComponentScan; 8 | import org.springframework.context.annotation.ComponentScan.Filter; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.context.annotation.FilterType; 11 | 12 | import com.graphql_java_generator.plugin.DocumentParser; 13 | import com.graphql_java_generator.util.GraphqlUtils; 14 | 15 | /** 16 | * @author EtienneSF 17 | */ 18 | @Configuration 19 | @ComponentScan(basePackageClasses = { DocumentParser.class, GraphqlUtils.class }, // 20 | excludeFilters = { @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateGraphQLSchema.*"), 21 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateClientCode.*"), 22 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateGraphQLSchema.*"), 23 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateServerCode.*") }) 24 | public class GeneratePojoSpringConfiguration { 25 | 26 | /** 27 | * The current GraphQL extension, that contains the plugin configuration. It is set by the 28 | * {@link GraphQLGenerateCodeTask} task, before it starts the Spring context 29 | */ 30 | static GeneratePojoTask graphqlPojoConf = null; 31 | 32 | @Bean 33 | GeneratePojoTask graphqlPojoConf() { 34 | return graphqlPojoConf; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /graphql-gradle-plugin3/src/main/java/com/graphql_java_generator/gradleplugin/GenerateServerCodeSpringConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.graphql_java_generator.gradleplugin; 5 | 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.ComponentScan; 8 | import org.springframework.context.annotation.ComponentScan.Filter; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.context.annotation.FilterType; 11 | 12 | import com.graphql_java_generator.plugin.DocumentParser; 13 | import com.graphql_java_generator.util.GraphqlUtils; 14 | 15 | /** 16 | * @author EtienneSF 17 | */ 18 | @Configuration 19 | @ComponentScan(basePackageClasses = { DocumentParser.class, GraphqlUtils.class }, // 20 | excludeFilters = { @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateClientCode.*"), 21 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateGraphQLSchema.*"), 22 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GeneratePojo.*"), 23 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GraphQL.*") }) 24 | public class GenerateServerCodeSpringConfiguration { 25 | 26 | /** 27 | * The current GraphQL extension, that contains the plugin configuration. It is set by the 28 | * {@link GenerateServerCodeTask} task, before it starts the Spring context 29 | */ 30 | static GenerateServerCodeTask generateServerCodeConf = null; 31 | 32 | @Bean 33 | GenerateServerCodeTask generateServerCodeConf() { 34 | return generateServerCodeConf; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /graphql-gradle-plugin3/src/main/java/com/graphql_java_generator/gradleplugin/GraphQLGenerateCodeSpringConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.graphql_java_generator.gradleplugin; 5 | 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.ComponentScan; 8 | import org.springframework.context.annotation.ComponentScan.Filter; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.context.annotation.FilterType; 11 | 12 | import com.graphql_java_generator.plugin.DocumentParser; 13 | import com.graphql_java_generator.util.GraphqlUtils; 14 | 15 | /** 16 | * @author EtienneSF 17 | */ 18 | @Configuration 19 | // @Import({ JacksonAutoConfiguration.class }) 20 | @ComponentScan(basePackageClasses = { DocumentParser.class, GraphqlUtils.class }, // 21 | excludeFilters = { @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateClientCode.*"), 22 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateGraphQLSchema.*"), 23 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GeneratePojo.*"), 24 | @Filter(type = FilterType.REGEX, pattern = ".*\\.GenerateServerCode.*") }) 25 | public class GraphQLGenerateCodeSpringConfiguration { 26 | 27 | /** 28 | * The current GraphQL extension, that contains the plugin configuration. It is set by the 29 | * {@link GraphQLGenerateCodeTask} task, before it starts the Spring context 30 | */ 31 | static GraphQLGenerateCodeTask graphqlGenerateCodeConf = null; 32 | 33 | @Bean 34 | GraphQLGenerateCodeTask graphqlGenerateCodeConf() { 35 | return graphqlGenerateCodeConf; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /graphql-gradle-plugin3/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | plugin.version = ${projectVersion} 2 | graphqlMavenPluginLogic.version = ${graphqlMavenPluginLogicVersion} 3 | -------------------------------------------------------------------------------- /graphql-gradle-plugin3/src/test/java/com/graphql_java_generator/gradleplugin/GraphQLPluginTest.java: -------------------------------------------------------------------------------- 1 | package com.graphql_java_generator.gradleplugin; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertNotEquals; 4 | import static org.junit.jupiter.api.Assertions.assertNotNull; 5 | 6 | import org.junit.jupiter.api.BeforeEach; 7 | import org.junit.jupiter.api.Test; 8 | 9 | public class GraphQLPluginTest { 10 | 11 | GraphQLPlugin graphQLPlugin; 12 | 13 | @BeforeEach 14 | void setup() { 15 | graphQLPlugin = new GraphQLPlugin(); 16 | } 17 | 18 | @Test 19 | void test_getVersion() { 20 | String version = graphQLPlugin.getVersion(); 21 | assertNotNull(version); 22 | assertNotEquals("${projectVersion}", version, "version is: '" + version + "'"); 23 | } 24 | 25 | @Test 26 | void test_getDependenciesVersion() { 27 | String version = graphQLPlugin.getDependenciesVersion(); 28 | assertNotNull(version); 29 | assertNotEquals("${graphqlMavenPluginLogicVersion}", version, "version is: '" + version + "'"); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /graphql-gradle-plugin3/src/test/resources/functionalTest/basic.graphqls: -------------------------------------------------------------------------------- 1 | type Query { 2 | getMsg: Message! 3 | } 4 | 5 | type Message { 6 | msg: String! 7 | } -------------------------------------------------------------------------------- /graphql-gradle-plugin3/src/test/resources/functionalTest/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.graphql-java-generator.graphql-gradle-plugin' 3 | } 4 | 5 | generateClientPojo { 6 | packageName = "org.functionalTest" 7 | generateJacksonAnnotations = false 8 | } -------------------------------------------------------------------------------- /graphql-gradle-plugin3/src/test/resources/functionalTest/build_generateServerCode.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | id 'com.graphql-java-generator.graphql-gradle-plugin' 4 | id 'org.springframework.boot' version "${springBootVersion}" 5 | id 'io.spring.dependency-management' version "${springDependencyManagementPluginVersion}" 6 | } 7 | 8 | repositories { 9 | // The plugin depends on the graphql-maven-plugin plugin logic module, which is in mavenCentral (for releases), and in mavenLocal 10 | // when working on the plugin development. 11 | mavenCentral() 12 | mavenLocal() // Only if you work on the plugin development 13 | } 14 | 15 | dependencies { 16 | // The graphql-java-client-dependencies module agregates all dependencies for the generated code 17 | implementation "com.graphql-java-generator:graphql-java-server-runtime:${project.version}" 18 | 19 | // Then, the dependencies that are specific to this project 20 | implementation "org.springframework.boot:spring-boot-starter-websocket" // Mandatory to activate the web sockets (mandatory for subscription) 21 | implementation "org.springframework.boot:spring-boot-starter-security" 22 | implementation "org.springframework.boot:spring-boot-starter-oauth2-resource-server" 23 | 24 | // This project uses some custom scalars from the graphql-java-extended-scalars module 25 | implementation "com.graphql-java:graphql-java-extended-scalars:${graphqlJavaExtendedScalarsVersion}" 26 | 27 | implementation "com.github.dozermapper:dozer-core:${dozerVersion}" 28 | } 29 | 30 | generateServerCode { 31 | packaging = 'war' 32 | } 33 | 34 | tasks.register('generateServerCodeRegister', com.graphql_java_generator.gradleplugin.GenerateServerCodeTask) { 35 | targetResourceFolder = '/build/generated-resources/generateServerCodeRegister' 36 | targetSourceFolder = '/build/generated-sources/generateServerCodeRegister' 37 | packaging = 'war' 38 | } 39 | -------------------------------------------------------------------------------- /graphql-gradle-plugin3/src/test/resources/functionalTest/build_registerTask.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java-library' 3 | id 'com.graphql-java-generator.graphql-gradle-plugin' 4 | id 'org.springframework.boot' version "${springBootVersion}" 5 | id 'io.spring.dependency-management' version "${springDependencyManagementPluginVersion}" 6 | } 7 | 8 | repositories { 9 | mavenCentral() 10 | // The plugin depends on the graphql-maven-plugin, whose snapshot versions are on the local maven repository. 11 | // So, for development reason, we need to access to the local maven repository. It's useless for standard use of the plugin 12 | mavenLocal() 13 | } 14 | 15 | dependencies { 16 | // And the Jackson annotations 17 | implementation "com.fasterxml.jackson.core:jackson-databind" 18 | // This project uses some custom scalars from the graphql-java-extended-scalars module 19 | implementation "com.graphql-java:graphql-java-extended-scalars:${graphqlJavaExtendedScalarsVersion}" 20 | } 21 | 22 | tasks.register('generateClientPojo', com.graphql_java_generator.gradleplugin.GeneratePojoTask) { 23 | packageName = "org.functionalTest" 24 | generateJacksonAnnotations = false 25 | mode = 'client' 26 | packaging = 'war' 27 | } -------------------------------------------------------------------------------- /graphql-gradle-plugin3/src/test/resources/functionalTest/build_usingExtension.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java-library' 3 | id 'com.graphql-java-generator.graphql-gradle-plugin' 4 | id 'org.springframework.boot' version "${springBootVersion}" 5 | id 'io.spring.dependency-management' version "${springDependencyManagementPluginVersion}" 6 | } 7 | 8 | repositories { 9 | mavenCentral() 10 | // The plugin depends on the graphql-maven-plugin, whose snapshot versions are on the local maven repository. 11 | // So, for development reason, we need to access to the local maven repository. It's useless for standard use of the plugin 12 | mavenLocal() 13 | } 14 | 15 | dependencies { 16 | // And the Jackson annotations 17 | implementation "com.fasterxml.jackson.core:jackson-databind" 18 | // This project uses some custom scalars from the graphql-java-extended-scalars module 19 | implementation "com.graphql-java:graphql-java-extended-scalars:${graphqlJavaExtendedScalarsVersion}" 20 | } 21 | 22 | generatePojo { 23 | packageName = "org.functionalTest" 24 | generateJacksonAnnotations = false 25 | mode = 'client' 26 | } -------------------------------------------------------------------------------- /graphql-gradle-plugin3/src/test/resources/functionalTest/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | maven { url "https://plugins.gradle.org/m2/" } 4 | gradlePluginPortal() 5 | } 6 | } 7 | 8 | rootProject.name = 'functionalTest' 9 | -------------------------------------------------------------------------------- /graphql-gradle-plugin3/src/test/resources/log4j2-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/5.4/userguide/multi_project_builds.html 8 | */ 9 | 10 | pluginManagement { 11 | includeBuild 'graphql-gradle-plugin' 12 | includeBuild 'graphql-gradle-plugin3' 13 | } 14 | 15 | rootProject.name = 'graphql-gradle-plugin-project' 16 | 17 | // graphql-gradle-plugin-samples-CustomTemplates-resttemplate must be built first 18 | // And, as we consume the resulting jar in the buildsrc section, it seems mandatory to build it as a separate build 19 | // (see the graphql-gradle-plugin-samples-allGraphQLCases-client subproject for its use) 20 | includeBuild 'graphql-gradle-plugin-samples-CustomTemplates-resttemplate' 21 | 22 | include 'graphql-gradle-plugin-samples-allGraphQLCases-client' 23 | include 'graphql-gradle-plugin-samples-allGraphQLCases-pojo-client' 24 | include 'graphql-gradle-plugin-samples-allGraphQLCases-pojo-client-jackson' 25 | include 'graphql-gradle-plugin-samples-allGraphQLCases-pojo-server' 26 | include 'graphql-gradle-plugin-samples-allGraphQLCases-client' 27 | include 'graphql-gradle-plugin-samples-allGraphQLCases-server' 28 | include 'graphql-gradle-plugin-samples-OAuth-authorization-server' 29 | include 'graphql-gradle-plugin-samples-Forum-client' 30 | include 'graphql-gradle-plugin-samples-Forum-server' 31 | --------------------------------------------------------------------------------