Skip to content

"GraphQL.ExecutionError: Null value provided for non-nullable argument 'field1'" - Even though it is actually not null. #268

@floge07

Description

@floge07

Hello again,

after I worked around #267 and then rolled out the new version, I discovered more obscure problems.
Some operations suddenly fail with the error mentioned in the title. No changes to the actual query or backend types were made.

The "ensure non null" validation seems to throw some new false positives.
If I remove the NonNull<> wrapper from that field it executes again, and there actually is a value!

This only happens on some operations. The thing that stands out about them is their complexity.
Looking at the request body, it's an operation with variables, which calls a query with one of the variables, and includes a fragment, which also uses a variable on one of it's methods.

An example:

query getStuffAndMore($var1: [String!]!, $var2: [String!]!, $var3: String) {
    getStuff(path: $var2, filter: $var3) {
        ...Fragment1
        ...on ErrorInfo {
            errorMessage
            errorCode
            __typename
        }
        __typename
    }
}

fragment Fragment1 on UnionType1 {
    more(field1: $var1)
}

I worked around it for now by removing the NonNull<> wrapper on the effected methods on the server side and instead added ArgumentNullException.ThrowIfNull() to the first line.

GraphQL: 8.2.1
GraphQL.Server.Transports.AspNetCore: 8.2.0
GraphQL.Convetions: 8.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions