Class GraphQLSchema

java.lang.Object
com.codename1.backend.graphql.GraphQLSchema

public final class GraphQLSchema extends Object

A schema read from GraphQL schema definition language, the .graphqls files Spring for GraphQL reads from src/main/resources/graphql.

The schema is checked when it is parsed: every type a field names must be defined, an object must declare every field of the interfaces it implements, and a union may only list object types. Each failure is a GraphQLException naming the type.

GraphQLSchema schema = GraphQLSchema.parse(
    "type Query { book(id: ID!): Book }\n"
  + "type Book { id: ID! title: String }");
  • Method Details

    • parse

      public static GraphQLSchema parse(String... sdl)
      Parses and checks a schema from one or more SDL documents, which are read as one: a type defined in one may be extended in another.
    • hasField

      public boolean hasField(String typeName, String fieldName)
      Whether this schema defines typeName.fieldName; the build uses this to match every resolver against the schema.
    • getTypeNames

      public List<String> getTypeNames()
      The names of the types this schema defines, the built-in ones included.
    • getRootTypeName

      public String getRootTypeName(String operation)
      The name of the root type for operation (query, mutation or subscription), or null when the schema has none.