Introduction
Schema testing helps make sure your GraphQL API is set up correctly. It checks that the types and fields match what you expect.
Jump into concepts and practice - no test required
Schema testing helps make sure your GraphQL API is set up correctly. It checks that the types and fields match what you expect.
query IntrospectionQuery {
__schema {
types {
name
kind
fields {
name
type {
name
kind
}
}
}
}
}query {
__schema {
queryType {
name
}
}
}query {
__type(name: "User") {
name
fields {
name
type {
name
kind
}
}
}
}This query checks the "Book" type in the schema, listing its fields and their types.
query {
__type(name: "Book") {
name
fields {
name
type {
name
kind
}
}
}
}Schema testing helps catch errors before clients use your API.
Use introspection queries to explore your schema anytime.
Keep your schema documentation updated as you change your API.
Schema testing checks your GraphQL API structure.
Use introspection queries to see types and fields.
It helps keep your API reliable and clear.
id (ID!) and name (String)?type followed by name and curly braces with fields.type User { id: ID! name: String }. Others misuse keywords or punctuation.type Query { user(id: ID!): User }{ user(id: "123") { id name } }data object with requested fields.id and name. Assuming user exists, response includes these inside data.email field exists on User type:expect(schema.getType('User').getFields()).toHaveProperty('email')getFields() method returns an object of fields defined on the type.User type lacks that field in schema definition.Post type has a field comments that returns a list of Comment types. Which test code correctly verifies this?[Comment!]!.