graphql-cost-analysis icon indicating copy to clipboard operation
graphql-cost-analysis copied to clipboard

Query with default values will cause error: "Argument \"input\" has invalid value...

Open robertu7 opened this issue 5 years ago • 3 comments

As title,

image

robertu7 avatar Jul 02 '19 12:07 robertu7

I'm getting this error when I've got custom scalars, when the custom scalar validation rejects the input: the nicely informative message from my custom scalar is not shown, but the error from graphql/execution/values.js#getArgumentValues (as in the stack trace above) is shown instead.

Is the correct function being called here? The particular exception block being triggered is commented:

          // Note: ValuesOfCorrectType validation should catch this before
          // execution. This is a runtime check to ensure execution does not
          // continue with an invalid argument value.

Looks like getArgumentValues is being called out-of-order as far as the execution pipeline is concerned?

ellispritchard avatar Aug 19 '19 15:08 ellispritchard

NB the original error from validation is also reported in the result, so ValuesOfCorrectType is also being run, but this doesn't stop related errors also being generated from the cost evaluation.

ellispritchard avatar Aug 20 '19 09:08 ellispritchard

I get exactly the same problem as the screenshot. This literally means the GraphQL API users can't pass $input variable like at all!

I believe this line passes wrong variables. https://github.com/pa-bru/graphql-cost-analysis/blob/b0f41119955654b52f8943ceaf4eb35dfb68db4e/src/costAnalysis.js#L349

koresar avatar Jan 29 '20 04:01 koresar