question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Querying single types by id partially fails when using Dataloader

See original GitHub issue

First thanks for this awesome project. And let’s come to my weird issue.

Describe the Issue When I try to query single entities from my ef core context using the CacheDataloader the query fails randomly a couple of times and then magically works. This issue only appears when I try to query different entities at a time.

To Reproduce Steps to reproduce the behavior:

  1. Create an EF Core Context with an Entity
  2. Add the Context to asp dependencies using AddDbContext
  3. Add a query to Schema
  4. Query to single entities by id in one query

Code I have this inside my RootQuery Schema

// User
descriptor.Field("user")
    .Argument("id", a => a.Type<NonNullType<IntType>>())
    .Type<UserType>()
    .Resolver( async ctx =>
    {
        var userId = ctx.Argument<int>("id");
        var data = await ctx.CacheDataLoader<int, User>("userById",
            id => ctx.Service<PanelContext>().Users.AsNoTracking()
                .FirstOrDefaultAsync(u => u.Id == userId)).LoadAsync(userId);
        
        return data;
    });

descriptor.Field("app")
    .Argument("id", a => a.Type<NonNullType<IntType>>())
    .Type<AppType>()
    .Resolver( async ctx =>
    {
        var appId = ctx.Argument<int>("id");
        var data = await ctx.CacheDataLoader<int, App>("appById",
            id => ctx.Service<PanelContext>().Apps.AsNoTracking()
                .FirstOrDefaultAsync(a => a.Id == appId)).LoadAsync(appId);
        
        return data;
    });

Here is a gif of this: https://imgur.com/pLumz9N

Not sure what is causing this.

Regards Artur

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:18 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
jrhodnikcommented, Apr 21, 2020

Excellent, I’m looking forward to it! Hot Chocolate and Strawberry Shake rock!

1reaction
michaelstaibcommented, Mar 8, 2020

This is now solved with the upcoming resource concept in 10.4

Read more comments on GitHub >

github_iconTop Results From Across the Web

Querying single types by id partially fails when using ...
When I try to query single entities from my ef core context using the CacheDataloader the query fails randomly a couple of times...
Read more >
Query regarding Partial loads (through data loader or ...
Query regarding Partial loads (through data loader or Database.insert with false paramater) with error record.
Read more >
"INVALID CROSS REFERENCE ID" IN DATALOADER
I am trying to do upsert through data loader.It is throwing the following error for all rows in the csv file.The ids used...
Read more >
Errors due to invalid IDs during Data Loader import and ...
Users may encounter the following errors when working in Data Loader: MALFORMED_ID: Object name id: id value of incorrect type.
Read more >
All about Upsert and External ID in Dataloader and Apex
If any one record will fail then none of contact record will be upserted. You may want to perform partial operation where if...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found