Skip to content

Commit 39e1cba

Browse files
committed
Rename the empty mutation type and hide __ fields from introspection
This makes GraphiQL stop emitting deprecation warnings
1 parent ab7e262 commit 39e1cba

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/schema/model.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl<'a> SchemaType<'a> {
117117
SchemaType {
118118
types: registry.types,
119119
query_type_name: query_type_name,
120-
mutation_type_name: if &mutation_type_name != "__EmptyMutation" { Some(mutation_type_name) } else { None },
120+
mutation_type_name: if &mutation_type_name != "_EmptyMutation" { Some(mutation_type_name) } else { None },
121121
directives: directives,
122122
}
123123
}

src/schema/schema.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ impl<'a, CtxT, QueryT, MutationT> GraphQLType for RootNode<'a, QueryT, MutationT
3434
graphql_object!(<'a> SchemaType<'a>: SchemaType<'a> as "__Schema" |&self| {
3535
field types() -> Vec<TypeType> {
3636
self.type_list()
37+
.into_iter()
38+
.filter(|t| t.to_concrete().map(|t| t.name() != Some("_EmptyMutation")).unwrap_or(false))
39+
.collect()
3740
}
3841

3942
field query_type() -> TypeType {
@@ -84,6 +87,7 @@ graphql_object!(<'a> TypeType<'a>: SchemaType<'a> as "__Type" |&self| {
8487
Some(fields
8588
.iter()
8689
.filter(|f| include_deprecated || f.deprecation_reason.is_none())
90+
.filter(|f| !f.name.starts_with("__"))
8791
.collect()),
8892
_ => None,
8993
}

src/types/scalars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl<T> GraphQLType for EmptyMutation<T> {
166166
type Context = T;
167167

168168
fn name() -> Option<&'static str> {
169-
Some("__EmptyMutation")
169+
Some("_EmptyMutation")
170170
}
171171

172172
fn meta<'r>(registry: &mut Registry<'r>) -> MetaType<'r> {

0 commit comments

Comments
 (0)