Bắt đầuIntrospection schema là gì
Introspection schema là gì
Introspection schema là cơ chế của GraphQL để cung cấp thông tin về schema, được truy xuất bằng chính ngôn ngữ GraphQL. Chính nhờ introspection mà các client như GraphiQL và GraphQL Voyager có thể giúp chúng ta tương tác với GraphQL schema.
Các client này luôn thực thi cùng một introspection query để lấy toàn bộ dữ liệu của schema:
query IntrospectionQuery {
__schema {
queryType {
name
}
mutationType {
name
}
subscriptionType {
name
}
types {
...FullType
}
directives {
name
description
locations
args {
...InputValue
}
}
}
}
fragment FullType on __Type {
kind
name
description
fields(includeDeprecated: true) {
name
description
args {
...InputValue
}
type {
...TypeRef
}
isDeprecated
deprecationReason
}
inputFields {
...InputValue
}
interfaces {
...TypeRef
}
enumValues(includeDeprecated: true) {
name
description
isDeprecated
deprecationReason
}
possibleTypes {
...TypeRef
}
}
fragment InputValue on __InputValue {
name
description
type {
...TypeRef
}
defaultValue
}
fragment TypeRef on __Type {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
}
}
}
}
}
}
}
}