Question: Generate GraphQL schema with just Types?See original GitHub issue
Is it possible to generate a simple schema based on a Java POJO without including any queries/mutations via GraphQLSchemaGenerator?
I tried the following:
public class TestPojo
private String test;
public String getTest()
and Schema generation code snippet:
return new GraphQLSchemaGenerator()
.withBasePackages( "com.xyz" )
.withOperationsFromTypes( TestPojo.class )
Is there any way to accomplish something like this?
When I create a simple TestQuery class and include the TestPojo object as a return type which is annotated with
@GraphQLQuery, I get the TestPojo type along with the query as expected.
I simply would like to build a schema where there are no queries but only types. Is this possible?
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
I see. I think the approach above gets you almost as close as possible to a types-only schema without violating the spec. I could theoretically make a method that removes the need for an explicit dummy, but it’s very dubious if that would make sense in the lib. That said, I’ll close this issue, but feel free to reopen if you’d like it addressed differently.
We have a legacy JMS Java API that we want to expose existing POJOs from as GraphQL types to our new frontend. Our frontend application connects to the same legacy application via parallel WS and we pipe the messages to the same JMS broker. We wanted our application to download the schema files containing GQL Types from JMS POJOs and uses them at the application layer. This way we can control both APIs from the same source.
I know this isn’t the most ideal design but it “gets us by” until we migrate everything over to GQL Queries/Mutations.