scalagraphqlsangria

Scala. Sangria.Print json schema


I am using GraphQL on Scala via Sangria. Also I am using apollo-codegen.

I want to define my schema once, so I export my scheme from backend to frontend by:

schema.renderPretty

The problem is sangria's renderPretty prints schema in schemaAst format. But apollo-codegen expects json format.

How to make sangria render schema in json format? Or maybe painless convert schemaAst to json via SBT?


Solution

  • I think you are referring to the introspection JSON. With Sangria you can get it by executing an introspection query:

    Executor.execute(schema, sangria.introspection.introspectionQuery)