mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 09:22:43 +03:00
fix empty input object types in introspection result when allowedFields for a type is empty (#412)
When there are no allowed fields for a type (via `TypePermissions`), engine creates related input object types (like `<TypeName>OrderBy`) with no fields. This results in an invalid introspection result. Client libraries fail with validation error. This PR fixes the issue. V3_GIT_ORIGIN_REV_ID: a45a56b1f503f6ab99f250884957b6fc723cf9c8
This commit is contained in:
parent
c60a2e7113
commit
1b4173011f
@ -4,7 +4,16 @@
|
||||
"__type": {
|
||||
"name": "ActorsByMovieArgs",
|
||||
"kind": "INPUT_OBJECT",
|
||||
"inputFields": []
|
||||
"inputFields": [
|
||||
{
|
||||
"name": "_no_fields_accessible",
|
||||
"type": {
|
||||
"kind": "SCALAR",
|
||||
"name": "String",
|
||||
"ofType": null
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -13,7 +22,16 @@
|
||||
"__type": {
|
||||
"name": "ActorsByMovieArgs",
|
||||
"kind": "INPUT_OBJECT",
|
||||
"inputFields": []
|
||||
"inputFields": [
|
||||
{
|
||||
"name": "_no_fields_accessible",
|
||||
"type": {
|
||||
"kind": "SCALAR",
|
||||
"name": "String",
|
||||
"ofType": null
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -252,6 +252,8 @@ fn object_type<'s, S: schema::SchemaContext>(
|
||||
})
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
// can't create dummy field inside the if-block, as it won't
|
||||
// live long enough
|
||||
let no_fields_accessible_name = mk_name!("_no_fields_accessible");
|
||||
let dummy_field = schema::Field::new(
|
||||
no_fields_accessible_name,
|
||||
@ -417,6 +419,20 @@ fn input_object_type<'s, S: schema::SchemaContext>(
|
||||
})
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
// can't create dummy field inside the if-block, as it won't
|
||||
// live long enough
|
||||
let no_fields_accessible_name = mk_name!("_no_fields_accessible");
|
||||
let dummy_field = schema::InputField::new(
|
||||
no_fields_accessible_name,
|
||||
None,
|
||||
S::introspection_node(),
|
||||
ast::TypeContainer::named_null(RegisteredTypeName::string()),
|
||||
None,
|
||||
schema::DeprecationStatus::NotDeprecated,
|
||||
);
|
||||
if allowed_fields.is_empty() {
|
||||
allowed_fields.push(&dummy_field)
|
||||
}
|
||||
allowed_fields.sort_by(|f1, f2| f1.name.cmp(&f2.name));
|
||||
array_response(&allowed_fields, |input_field| {
|
||||
input_value(schema, namespace, input_field, &field.selection_set)
|
||||
|
Loading…
Reference in New Issue
Block a user