eslint-plugin-graphql icon indicating copy to clipboard operation
eslint-plugin-graphql copied to clipboard

Missing Non-Null marked input type not detected

Open jacobk opened this issue 8 years ago • 1 comments
trafficstars

Intended outcome:

Detect that resendUserVerificationInput is supposed to be Non-Null in this query:

#import "fragments/mutationResponseFields.gql"

mutation ResendVerification($input: resendUserVerificationInput) {
  resendUserVerification(input: $input) {
    resendUserVerification {
      user {
        id
        phoneNumber
      }
      ...mutationResponseFields
    }
  }
}

The same query in Graphiql yields this error: screen shot 2017-03-13 at 08 36 27

Actual outcome:

No error is detected when linting

How to reproduce the issue:

If I introduce a deliberate error e.g. misspell resendUserVerificationInput above errors are properly detected:

/Users/jacob/Code/foo/app/containers/ResendVerification/resendVerification.gql
  4:37  error  Unknown type "resendUserVerificationInputs". Did you mean "resendUserVerificationInput" or "resendUserVerificationPayload"?  graphql/template-strings

My graphql/template-strings configuration:

      "graphql/template-strings": [
        "error",
        {
          "env": "literal",
          "schemaJsonFilepath": "app/schema.json",
          "validators": [
            "ArgumentsOfCorrectType",
            "DefaultValuesOfCorrectType",
            "FieldsOnCorrectType",
            "FragmentsOnCompositeTypes",
            "KnownArgumentNames",
            "KnownTypeNames",
            "LoneAnonymousOperation",
            "NoFragmentCycles",
            "NoUndefinedVariables",
            "NoUnusedVariables",
            "OverlappingFieldsCanBeMerged",
            "PossibleFragmentSpreads",
            "ProvidedNonNullArguments",
            "ScalarLeafs",
            "UniqueArgumentNames",
            "UniqueFragmentNames",
            "UniqueInputFieldNames",
            "UniqueOperationNames",
            "UniqueVariableNames",
            "VariablesAreInputTypes"
          ]
        }
      ]

Excerpt from schema.json for related mutation indicating non null:

{
  "args" : [ {
    "defaultValue" : null,
    "name" : "input",
    "description" : null,
    "type" : {
      "kind" : "NON_NULL",
      "name" : null,
      "ofType" : {
        "kind" : "INPUT_OBJECT",
        "name" : "resendUserVerificationInput",
        "ofType" : null
      }
    }
  } ],
  "deprecationReason" : null,
  "isDeprecated" : false,
  "name" : "resendUserVerification",
  "description" : "resendUserVerification",
  "type" : {
    "kind" : "OBJECT",
    "name" : "resendUserVerificationPayload",
    "ofType" : null
  }
}

jacobk avatar Mar 13 '17 07:03 jacobk

I had the same thing today-this is not marked as a problem:

image

even though my schema has attending arg as nullable. Yet it works when I mismatch type for userId:

image

capaj avatar Jul 17 '19 13:07 capaj