Class GraphQLSchemaParser

java.lang.Object
org.brapi.schematools.core.graphql.GraphQLSchemaParser

public class GraphQLSchemaParser extends Object
Parser for converting the result of a introspection query into a GraphQLSchema, and vice versa.
  • Constructor Details

    • GraphQLSchemaParser

      public GraphQLSchemaParser()
      Creates a new Parser with a standard ObjectMapper
    • GraphQLSchemaParser

      public GraphQLSchemaParser(com.fasterxml.jackson.databind.ObjectMapper mapper)
      Creates a new Parser with a predefined ObjectMapper
      Parameters:
      mapper - a predefined ObjectMapper
  • Method Details

    • parseJsonSchema

      public graphql.schema.GraphQLSchema parseJsonSchema(String jsonSchema) throws com.fasterxml.jackson.core.JsonProcessingException
      Parses the result of an introspection query into a GraphQLSchema. Note the schema is not executable.
      Parameters:
      jsonSchema - the result of an introspection query into a GraphQLSchema
      Returns:
      A GraphQLSchema generated from the result of an introspection query
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - if there is a problem reading the schema as a valid JSON object.
    • writeSchemaToString

      public String writeSchemaToString(graphql.schema.GraphQLSchema schema) throws com.fasterxml.jackson.core.JsonProcessingException
      Writes the schema to a String.
      Parameters:
      schema - A GraphQLSchema generated from the result of an introspection query
      Returns:
      A string version of the JSON representing a GraphQLSchema generated from the result of an introspection query
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - if there is a problem writing the schema as a valid JSON object.