smallrye / smallrye-graphql

Implementation for MicroProfile GraphQL
Apache License 2.0
160 stars 92 forks source link

How get GraphQL schema as String ? #1278

Closed rullyalves closed 2 years ago

rullyalves commented 2 years ago

Hello, I'm trying to integrate this library with Neo4j graphl, I would like to know how I could retrieve the GraphQL schema as a similar Stringq with: type Person { name: ID! age: Int }

phillip-kruger commented 2 years ago

So you are not using it with a runtime like Quarkus or Wildfly ? If you use this directly and you use the CDI module, you should be able to inject GraphQLSchema (see https://github.com/smallrye/smallrye-graphql/blob/4c18d5773e599b8f86ccdd1d23a15c0cb7cb34e5/server/implementation-cdi/src/main/java/io/smallrye/graphql/cdi/producer/GraphQLProducer.java#L47) and then use SchemaPrinter to get a String version (see https://github.com/smallrye/smallrye-graphql/blob/4c18d5773e599b8f86ccdd1d23a15c0cb7cb34e5/server/implementation-servlet/src/main/java/io/smallrye/graphql/entry/http/SchemaServlet.java#L30)

Hope that help

phillip-kruger commented 2 years ago

closing, no feedback