Skip to content

UseProjection breaks @defer and loads everything in one go #5478

Open
@DavidErben

Description

@DavidErben

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When using the UseProjection attribute, @defer does not work anymore. I could not find any info if this scenario is currently not supported or if it is a bug.

Easily reproducible with this setup:

    public class Book
    {
        public string Cheap => "Foo";
        public async Task<string> Expensive()
        {
            await Task.Delay(10000);
            return "Bar";
        }
    }

    public class Query
    {
        private static readonly Book _book = new();

        public Book GetBook() => _book;
    }

Then sending this query:

query Test {
  book {
    cheap
    ... @defer(label: "deferredValue") {
      expensive
    }
  }
}

grafik

Works perfectly fine. If you put [UseProjection] on the GetBook method it breaks and takes 10 seconds to load with the same query.

    public class Query
    {
        private static readonly Book _book = new();

        [UseProjection]
        public Book GetBook() => _book;
    }

grafik

This issue is maybe linked to the same problem: #5386

Steps to reproduce

  1. Use code from above without UseProjection attribute -> works fine
  2. Put UseProjection attribute on GetBook method -> does not work anymore, loading takes 10 seconds even with @defer

Relevant log output

No response

Additional Context?

No response

Product

Hot Chocolate

Version

12.15.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions