Schema

class Schema

A wrapper around a schema GQLDocument that ensures the GQLDocument is valid and caches some extra information. In particular, Schema:

  • always contain builtin definitions (SDL can omit them)

  • always has a schema definition for easier lookup of root operation types

  • has all type system extensions merged

  • has some helper functions to retrieve a type by name and/or possible types

  • caches keyFields for easier lookup during codegen

  • remembers foreignNames to keep track of renamed definitions

  • remembers directivesToStrip to keep track of client-only directives

Parameters

definitions

a list of validated and merged definitions

keyFields

a Map containing the key fields for each type

foreignNames

a Map from a type system name -> its original name in the foreign schema. To distinguish between directives and types, directive names must be prefixed by '@' Example: "@kotlin_labs_nonnull" -> "@nonnull"

directivesToStrip

directives to strip because they are coming from a foreign schema Example: "kotlin_labs_nonnull"

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Returns whether the typePolicy directive is present on at least one object in the schema

Link copied to clipboard

List all types (types, interfaces, unions) implemented by a given type (including itself)

Link copied to clipboard
fun isTypeASubTypeOf(type: String, superType: String): Boolean
Link copied to clipboard
fun isTypeASuperTypeOf(type: String, subType: String): Boolean
Link copied to clipboard
fun keyFields(name: String): Set<String>

Get the key fields for an object, interface or union type.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun possibleTypes(typeDefinition: GQLTypeDefinition): Set<String>

returns all possible types:

Link copied to clipboard
fun rootTypeNameFor(operationType: String): String
Link copied to clipboard
fun rootTypeNameOrNullFor(operationType: String): String?
Link copied to clipboard

return whether the given directive should be removed from operation documents before being sent to the server

Link copied to clipboard
fun superTypes(objectTypeDefinition: GQLObjectTypeDefinition): Set<String>

List all direct super types (interfaces, unions) implemented by a given object type

Link copied to clipboard
Link copied to clipboard
fun toMap(): Map<String, Any>

Returns the Schema as a Map that can be easily serialized to Json

Link copied to clipboard