Skip to content

Commit cfed1bc

Browse files
committed
Workaround
1 parent b3c769f commit cfed1bc

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/ast/operation_visitor.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,22 @@ fn visit_definitions<'a, Visitor, UserContext>(
167167
Definition::Operation(operation) => match operation {
168168
OperationDefinition::Query(_) => Some(&context.schema.query_type().name),
169169
OperationDefinition::SelectionSet(_) => Some(&context.schema.query_type().name),
170-
OperationDefinition::Mutation(_) => context.schema.mutation_type().map(|t| &t.name),
170+
OperationDefinition::Mutation(_) => {
171+
context.schema.mutation_type().map(|t| &t.name).or_else(|| {
172+
// Awkward hack but enables me to move forward
173+
// Somehow the `mutation_type()` gives None, even though `Mutation` type is defined in the schema.
174+
if let Some(type_definition) = context.schema.type_by_name("Mutation") {
175+
return match type_definition {
176+
graphql_parser::schema::TypeDefinition::Object(object_type) => {
177+
Some(&object_type.name)
178+
}
179+
_ => None,
180+
};
181+
}
182+
183+
None
184+
})
185+
}
171186
OperationDefinition::Subscription(_) => {
172187
context.schema.subscription_type().map(|t| &t.name)
173188
}

0 commit comments

Comments
 (0)