Skip to content

Unhelpful error when a non-existing type is referenced as a Field's type #3034

@jasonbahl

Description

@jasonbahl

Description

When a field references a GraphQL Type that does not exist, the error returned when the schema fails to load isn't clear on what the problem is or how to fix it.

Steps to reproduce

  1. register a mutation like so:
<?php
add_action( 'graphql_register_types', function() {

  register_graphql_mutation( 'testMutation', [
    'inputFields' => [ 'test' => [ 'type' => 'String' ] ],
    'outputFields' => [ 'test' => [ 'type' => 'NonExistantType' ] ],
    'mutateAndGetPayload' => function( $input, $context, $info ) { return true; }
  ] );

} );
?>
  1. Open the GraphiQL IDE and see the schema fails to load
  2. Inspect the network response
  3. See the "Internal Server Error" without a whole lot of information to help debug

Expectation

I would expect the "Internal Server Error" to mention something explicit like "NonExistantType" referenced on the "TestMutationPayload.answer" field is not a registered Type in the Schema. Or something along those lines. 🤔

Additional context

No response

WPGraphQL Version

1.20.0

WordPress Version

latest

PHP Version

8..2

Additional environment details

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have disabled ALL plugins except for WPGraphQL.

  • Yes
  • My issue is with compatibility with a specific WordPress plugin, and I have listed all my installed plugins (and version info) above.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions