graphql-java-generator / graphql-gradle-plugin-project

graphql-gradle-plugin is a Gradle Plugin for GraphQL, based on graphql-java. It accelerates the development for both the client and the server, by generating the Java code. It allows a quicker development when in contract-first approach, by avoiding to code the boilerplate code.
https://graphql-maven-plugin-project.graphql-java-generator.com/
MIT License
54 stars 8 forks source link

Multiple Schema EndPoints Same Spring Boot Project #19

Closed razilevin closed 9 months ago

razilevin commented 9 months ago

I wonder if there is a way to generate 2 sets of pojos and have them work in a Spring Boot application. E.g. each set of bindings would need to have its own Webclient due to the need to call separate endpoints. This snippet does not seem to work.

generateClientCode {
    packageName = 'org.client.pojo.cs'
    schemaFileFolder = './src/main/resources/contentstack'
    skipGenerationIfSchemaHasNotChanged = true
    targetSourceFolder = 'build/generated/sources/'
    customScalars = [
            [
                    graphQLTypeName             : "DateTime",
                    javaType                    : "java.time.OffsetDateTime",
                    graphQLScalarTypeStaticField: "graphql.scalars.ExtendedScalars.DateTime"
            ],
            [
                    graphQLTypeName             : "JSON",
                    javaType                    : "java.lang.String",
                    graphQLScalarTypeStaticField: "graphql.Scalars.GraphQLString"
            ]
    ]
}

generateClientCode {
    packageName = 'org.client.pojo.sf'
    schemaFileFolder = './src/main/resources/salesforce'
    skipGenerationIfSchemaHasNotChanged = true
    targetSourceFolder = 'build/generated/sources/'
    customScalars = [
            [
                    graphQLTypeName             : "DateTime",
                    javaType                    : "java.time.OffsetDateTime",
                    graphQLScalarTypeStaticField: "graphql.scalars.ExtendedScalars.DateTime"
            ],
            [
                    graphQLTypeName             : "JSON",
                    javaType                    : "java.lang.String",
                    graphQLScalarTypeStaticField: "graphql.Scalars.GraphQLString"
            ]
    ]
}

It only generates one set of pojos

razilevin commented 9 months ago

I will update this issue just in case people need to find this.

There is a sample project that shows an example of how to do this in gradle.

https://github.com/graphql-java-generator/graphql-gradle-plugin-project/blob/master_2.x/graphql-gradle-plugin-samples-allGraphQLCases-client/build.gradle