Skip to content

NRE when Resolve property of ObjectType with ParentRequires #9788

@stanislav-a-frolov

Description

@stanislav-a-frolov

Product

Hot Chocolate

Version

16.0.9

Link to minimal reproduction

https://github.com/stanislav-a-frolov/TestResolverRequiredField

Steps to reproduce

Add Resolve field of ObjectType using ParentRequires to schema:

        var executor = await new ServiceCollection()
            .AddGraphQL()
            .AddQueryType(q => q
                .Field("foo")
                .Resolve(ctx => new[] { new Foo { Bar = new() } }.AsQueryable())
                .UseProjection()
                )
            .AddObjectType<Foo>(c =>
            {
                c.Field(f => f.Bar);
                c.Field("quux")
                    .Resolve(c => c.Parent<Foo>().Bar)
                    .ParentRequires<Foo>(f => f.Bar!);
            })
            .AddProjections()
            .BuildRequestExecutorAsync();

Query the field foo.quux.bar and get an NRE in reponse

What is expected?

Field is expected to be resolved without errors.

What is actually happening?

NRE is thrown in OperationCompiler.CompileSelectionSet

Relevant log output

Additional context

No response

Metadata

Metadata

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions