Question: Generate GraphQL schema with just Types?
See original GitHub issueHello,
Is it possible to generate a simple schema based on a Java POJO without including any queries/mutations via GraphQLSchemaGenerator?
I tried the following:
@GraphQLType
public class TestPojo
{
private String test;
public String getTest()
{
return test;
}
}
and Schema generation code snippet:
return new GraphQLSchemaGenerator()
.withBasePackages( "com.xyz" )
.withOperationsFromTypes( TestPojo.class )
.generate();
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?
Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Generated GraphQL Schemas and Schema Design
A GraphQL schema is a machine and human-readable document that declares what operations are available and what types those operations return.
Read more >Schemas and Types - GraphQL
The most basic components of a GraphQL schema are object types, which just represent a kind of object you can fetch from your...
Read more >Generating TypeScript Types for GraphQL Schema ... - YouTube
In this video I'll show how to generate TypeScript types for GraphQL schema, resolvers, queries and mutations using GraphQL Code Generator.
Read more >Generating TypeScript Types from GraphQL Schema in Apollo
In this video we'll see how to generate TypeScript types automatically from our GraphQL queries using Apollo.
Read more >Generate GraphQL schema from TypeScript? - Stack Overflow
type -graphql only works if all custom types are class es. That doesn't work for me; I don't have a single class but...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.