apollographql / apollo-rs

Spec compliant GraphQL Tools in Rust.
Apache License 2.0
574 stars 45 forks source link

Validation: forbid __schema outside of the root type #903

Closed Geal closed 1 month ago

Geal commented 2 months ago

According to @IvanGoncharov , __schema should not be used outside of the root type: https://github.com/apollographql/router/pull/5255#discussion_r1699109946

Do we check this somewhere?

SimonSapin commented 2 months ago

In a typical schema, non-root types don’t have a __schema field so converting AST to an ExecutableDocument would fail with a BuildError::UndefinedField. In code, meta-fields like __schema are not present in the Rust struct ObjecType.fields but are returned if you instead call schema.type_field(type_name, field_name).

Defining a schema like type Something { __schema: Int } is disallowed per spec but we don’t yet implement that validation rule: https://github.com/apollographql/apollo-rs/issues/743

SimonSapin commented 1 month ago

Closing as duplicate of https://github.com/apollographql/apollo-rs/issues/743