How to get the generated scheme file .graphqls using SPQR?

How to get the generated scheme file .graphqls using SPQR?



I really like the way SPQR makes easy to integrate graphql with an existing system, the only thing I'd like to see is the .graphqls file so I can learn more on GraphQL Syntax.


.graphqls



Is there a way to generate the scheme file from an existing code with SPQR annotations integrated?



To provide some code let's use the same code from the GitHub site



Entity:


public class User

private String name;
private Integer id;
private Date registrationDate;

@GraphQLQuery(name = "name", description = "A person's name")
public String getName()
return name;


@GraphQLQuery
public Integer getId()
return id;


@GraphQLQuery(name = "regDate", description = "Date of registration")
public Date getRegistrationDate()
return registrationDate;




Service class:


class UserService

@GraphQLQuery(name = "user")
public User getById(@GraphQLArgument(name = "id") Integer id)
...




Expected Output:


type User
id: Int!
name: String!
registrationDate: String


Query
user(Int):User




1 Answer
1



This is not really SPQR specific. All the needed classes are provided by graphql-java itself:


new SchemaPrinter().print(schema);



To get a more detailed output (with scalars, introspection types etc), provide the options to the printer:


new SchemaPrinter(
// Tweak the options accordingly
SchemaPrinter.Options.defaultOptions()
.includeScalarTypes(true)
.includeExtendedScalarTypes(true)
.includeIntrospectionTypes(true)
.includeSchemaDefintion(true)
).print(schema);



Required, but never shown



Required, but never shown






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)