ardatan / graphql-mesh

🕸️ GraphQL Federation Framework for any API services such as REST, OpenAPI, Swagger, SOAP, gRPC and more...
https://the-guild.dev/graphql/mesh
MIT License
3.26k stars 332 forks source link

Failed validation, i.e. additional field not present in schema, leads to duplicate responses, no context enhancements possible, introspection query and empty result.. #6259

Open PlayAnyData opened 10 months ago

PlayAnyData commented 10 months ago

Issue workflow progress

Progress of the issue based on the Contributor Workflow

Execution instructions are in the repo in the readme.


Describe the bug

We have created a mesh of different subgraphs. Now, if somebody sends a request with a non-existing field, i.e. query myQuery{ myQuery { items { id toast } } } where toast does not exist in the schema, we face the following issues: The query runs through the following plugin steps:

parse validate (here we can see validation failed) parse (now we have an introspection query for schema) validate execute (here we can see the result of the introspection query)

We are wondering why it is running through the second parse - validate cycle. From debugging we know in this case it sends an introspection query. Even if we tried disabling introspection, e.g. via envelop plugin, it still runs through this second phase.

Additionally, in executeDone we can only see the results of the introspection query, but not the original query's results.

The displayed result, then shows something like this: { "errors": [ { "message": "Field \"toast\" is not defined by type \"myQuery_type\"." }, { "message": "Field \"toast\" is not defined by type \"myQuery_type\"." } ] }

So the result is duplicated.

To Reproduce Steps to reproduce the behavior:

  1. Create a mesh with a query.
  2. Execute a query with a non-existing field.

Expected behavior

We would have expected to see the validation result in execute phase, or even a context attribute, which we set in the validate phase, with which we would be able to skip execution. However, we can only see the introspection query here.

Environment:

Additional context What we are trying to achieve is creating prometheus metrics with result status codes from all calls filtered by operationName, client, etc. therefore, we would also like to know who is potentially writing bad requests e.g. after a version upgrade.

ardatan commented 10 months ago

Thanks for creating the issue, but we need a reproduction as you can see in the issue template.

PlayAnyData commented 10 months ago

Added repo for reproduction.