Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graphql: update introspection schema #4676

Merged
merged 5 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion graph/src/schema/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use inflector::Inflector;
use lazy_static::lazy_static;

use crate::components::store::EntityType;
use crate::data::graphql::ObjectOrInterface;
use crate::data::graphql::{ObjectOrInterface, ObjectTypeExt};
use crate::schema::{ast, META_FIELD_NAME, META_FIELD_TYPE};

use crate::data::graphql::ext::{DirectiveExt, DocumentExt, ValueExt};
Expand Down Expand Up @@ -233,6 +233,13 @@ lazy_static! {
let schema = include_str!("introspection.graphql");
parse_schema(schema).expect("the schema `introspection.graphql` is invalid")
};
pub static ref INTROSPECTION_QUERY_TYPE: ast::ObjectType = ast::ObjectType::from(Arc::new(
INTROSPECTION_SCHEMA.get_root_query_type().unwrap().clone()
));
}

pub fn is_introspection_field(name: &str) -> bool {
INTROSPECTION_QUERY_TYPE.field(name).is_some()
}

fn add_introspection_schema(schema: &mut Document) {
Expand Down
14 changes: 11 additions & 3 deletions graph/src/schema/introspection.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# API schema.

type __Schema {
description: String
types: [__Type!]!
queryType: __Type!
mutationType: __Type
Expand Down Expand Up @@ -33,12 +34,15 @@ type __Type {

# NON_NULL and LIST only
ofType: __Type

# may be non-null for custom SCALAR, otherwise null.
specifiedByURL: String
}

type __Field {
name: String!
description: String
args: [__InputValue!]!
args(includeDeprecated: Boolean = false): [__InputValue!]!
type: __Type!
isDeprecated: Boolean!
deprecationReason: String
Expand All @@ -49,6 +53,8 @@ type __InputValue {
description: String
type: __Type!
defaultValue: String
isDeprecated: Boolean!
deprecationReason: String
}

type __EnumValue {
Expand All @@ -73,7 +79,8 @@ type __Directive {
name: String!
description: String
locations: [__DirectiveLocation!]!
args: [__InputValue!]!
args(includeDeprecated: Boolean = false): [__InputValue!]!
isRepeatable: Boolean!
dotansimha marked this conversation as resolved.
Show resolved Hide resolved
}

enum __DirectiveLocation {
Expand All @@ -84,6 +91,7 @@ enum __DirectiveLocation {
FRAGMENT_DEFINITION
FRAGMENT_SPREAD
INLINE_FRAGMENT
VARIABLE_DEFINITION
SCHEMA
SCALAR
OBJECT
Expand All @@ -95,4 +103,4 @@ enum __DirectiveLocation {
ENUM_VALUE
INPUT_OBJECT
INPUT_FIELD_DEFINITION
}
}
2 changes: 1 addition & 1 deletion graph/src/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub mod ast;
mod fulltext;
mod input_schema;

pub use api::{api_schema, APISchemaError};
pub use api::{api_schema, is_introspection_field, APISchemaError, INTROSPECTION_QUERY_TYPE};

pub use api::{ApiSchema, ErrorPolicy};
pub use fulltext::{FulltextAlgorithm, FulltextConfig, FulltextDefinition, FulltextLanguage};
Expand Down
3 changes: 1 addition & 2 deletions graphql/src/execution/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use graph::{
value::{Object, Word},
},
prelude::{s, CheapClone},
schema::META_FIELD_NAME,
schema::{is_introspection_field, INTROSPECTION_QUERY_TYPE, META_FIELD_NAME},
util::{lfu_cache::EvictStats, timed_rw_lock::TimedMutex},
};
use lazy_static::lazy_static;
Expand All @@ -24,7 +24,6 @@ use graph::util::{lfu_cache::LfuCache, stable_hash_glue::impl_stable_hash};

use super::QueryHash;
use crate::execution::ast as a;
use crate::introspection::{is_introspection_field, INTROSPECTION_QUERY_TYPE};
use crate::prelude::*;

lazy_static! {
Expand Down
2 changes: 0 additions & 2 deletions graphql/src/introspection/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
mod resolver;
mod schema;

pub use self::resolver::IntrospectionResolver;
pub use self::schema::{is_introspection_field, INTROSPECTION_DOCUMENT, INTROSPECTION_QUERY_TYPE};
132 changes: 0 additions & 132 deletions graphql/src/introspection/schema.rs

This file was deleted.