Skip to content

Commit

Permalink
Merge pull request #501 from jimmystewpot/oneOf_support_in_introspect…
Browse files Browse the repository at this point in the history
…ion_query

extend introspection schema to include oneOf and specifiedByURL
  • Loading branch information
tomhoule authored Dec 18, 2024
2 parents 9b91a7f + de796b3 commit 303ed67
Show file tree
Hide file tree
Showing 9 changed files with 402 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
query IntrospectionQueryWithIsOneOfSpecifiedByURL {
__schema {
queryType {
name
}
mutationType {
name
}
subscriptionType {
name
}
types {
...FullTypeWithisOneOfSpecifiedByURL
}
directives {
name
description
locations
args {
...InputValue
}
}
}
}

fragment FullTypeWithisOneOfSpecifiedByURL on __Type {
kind
name
description
isOneOf
specifiedByURL
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
}
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
query IntrospectionQueryWithIsOneOf {
__schema {
queryType {
name
}
mutationType {
name
}
subscriptionType {
name
}
types {
...FullTypeWithisOneOf
}
directives {
name
description
locations
args {
...InputValue
}
}
}
}

fragment FullTypeWithisOneOf on __Type {
kind
name
description
isOneOf
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
}
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
query IntrospectionQueryWithSpecifiedBy {
__schema {
queryType {
name
}
mutationType {
name
}
subscriptionType {
name
}
types {
...FullTypeWithSpecifiedBy
}
directives {
name
description
locations
args {
...InputValue
}
}
}
}

fragment FullTypeWithSpecifiedBy on __Type {
kind
name
description
specifiedByURL
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
}
}
}
}
}
}
}
}
8 changes: 8 additions & 0 deletions graphql_client_cli/src/graphql/introspection_schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ type __Type {

# NON_NULL and LIST only
ofType: __Type

# may be non-null for custom SCALAR, otherwise null.
# https://spec.graphql.org/draft/#sec-Scalars.Custom-Scalars
specifiedByURL: String
specifiedBy: String

# should be non-null for INPUT_OBJECT only
isOneOf: Boolean
}

type __Field {
Expand Down
41 changes: 41 additions & 0 deletions graphql_client_cli/src/introspection_queries.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use graphql_client::GraphQLQuery;

#[derive(GraphQLQuery)]
#[graphql(
schema_path = "src/graphql/introspection_schema.graphql",
query_path = "src/graphql/introspection_query.graphql",
response_derives = "Serialize",
variable_derives = "Deserialize"
)]
#[allow(dead_code)]
pub struct IntrospectionQuery;

#[derive(GraphQLQuery)]
#[graphql(
schema_path = "src/graphql/introspection_schema.graphql",
query_path = "src/graphql/introspection_query_with_is_one_of.graphql",
response_derives = "Serialize",
variable_derives = "Deserialize"
)]
#[allow(dead_code)]
pub struct IntrospectionQueryWithIsOneOf;

#[derive(GraphQLQuery)]
#[graphql(
schema_path = "src/graphql/introspection_schema.graphql",
query_path = "src/graphql/introspection_query_with_specified_by.graphql",
response_derives = "Serialize",
variable_derives = "Deserialize"
)]
#[allow(dead_code)]
pub struct IntrospectionQueryWithSpecifiedBy;

#[derive(GraphQLQuery)]
#[graphql(
schema_path = "src/graphql/introspection_schema.graphql",
query_path = "src/graphql/introspection_query_with_isOneOf_specifiedByUrl.graphql",
response_derives = "Serialize",
variable_derives = "Deserialize"
)]
#[allow(dead_code)]
pub struct IntrospectionQueryWithIsOneOfSpecifiedByURL;
Loading

0 comments on commit 303ed67

Please sign in to comment.