Skip to content

No validation rule exists to assert mutation/subscription operations exist in the schema #1097

Closed
@Shane32

Description

@Shane32

When validating a document against a schema, there exists various validation rules for operations, but none to verify that if a mutation or subscription operation type is requested, that the schema is configured for such an operation.

For example, the below document would current pass all defined validation checks even with no mutation operation defined in the schema:

mutation {
  __typename
}

While per 6.2.2 the execution phase would fail the assertion that "mutationType is an Object type" and would fail to execute, this problem should be caught during validation, not execution.

Note that in the above sample, only 5.3.1 Field Selections could possibly fail validation. For GraphQL.NET, each validation rule assumes that prior validation steps have passed. For example, we do not raise errors about invalid fields when the parent field does not exist. So no error is raised due to 5.3.1. Further, __typename is a meta-field and would be not be compared to the schema in any case. We perform the assertion at the execution step pursuant to the GraphQL spec.

I suggest adding validation rule 5.2.4 indicating that for mutation or subscription operation types, the schema must be configured for the requested operation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions