Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OffsetPaging with DatabaseContext. Items and TotalCount #2461

Closed
sergeyshaykhullin opened this issue Oct 19, 2020 · 0 comments · Fixed by #2480
Closed

OffsetPaging with DatabaseContext. Items and TotalCount #2461

sergeyshaykhullin opened this issue Oct 19, 2020 · 0 comments · Fixed by #2480
Assignees
Labels
🔍 investigate Indicates that an issue or pull request needs more information.
Projects
Milestone

Comments

@sergeyshaykhullin
Copy link
Contributor

sergeyshaykhullin commented Oct 19, 2020

Describe the bug
.UsePaging() is working, but .UseOffsetPaging() failing with disposed db context exception/returning nulls instead of field values

To Reproduce

descriptor.Field<RequestSentResolvers>(r => r.SentLogs(default!))
	.Type<ListType<SentLogType>>()
	.UseDbContext<DatabaseContext>()
	// .UsePaging()
        .UseOffsetPaging()
	.UseProjection()
	.UseFiltering()
	.UseSorting();

Expected behavior

Working as .UsePaging()

Desktop (please complete the following information):

  • OS: Windows
  • Version 10

Additional context

  1. With totalCount
query A {
  sentLogs {
    items {
      text
    }
   pageInfo {
     hasNextPage
     hasPreviousPage
   }
   totalCount
  }
}
{
  "errors": [
    {
      "message": "Unexpected Execution Error",
      "locations": [
        {
          "line": 10,
          "column": 5
        }
      ],
      "path": [
        "sentLogs",
        "totalCount"
      ],
      "extensions": {
        "message": "Cannot access a disposed context instance. A common cause of this error is disposing a context instance that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling 'Dispose' on the context instance, or wrapping it in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances.\r\nObject name: 'DatabaseContext'.",
        "stackTrace": "   at Microsoft.EntityFrameworkCore.DbContext.CheckDisposed()\r\n   at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()\r\n   at Microsoft.EntityFrameworkCore.DbContext.Microsoft.EntityFrameworkCore.Internal.IDbContextDependencies.get_StateManager()\r\n   at Microsoft.EntityFrameworkCore.Query.QueryContextDependencies.get_StateManager()\r\n   at Microsoft.EntityFrameworkCore.Query.QueryContext.InitializeStateManager(Boolean standAlone)\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.Enumerator.InitializeReader(DbContext _, Boolean result)\r\n   at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.Enumerator.MoveNext()\r\n   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)\r\n   at System.Linq.Queryable.Count[TSource](IQueryable`1 source)\r\n   at System.Threading.Tasks.Task`1.InnerInvoke()\r\n   at System.Threading.Tasks.Task.<>c.<.cctor>b__277_0(Object obj)\r\n   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)\r\n--- End of stack trace from previous location ---\r\n   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)\r\n   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)\r\n--- End of stack trace from previous location ---\r\n   at HotChocolate.Types.Pagination.QueryableOffsetPagingHandler`1.<>c__DisplayClass1_0.<<SliceAsync>g__CountAsync|0>d.MoveNext()\r\n--- End of stack trace from previous location ---\r\n   at HotChocolate.Resolvers.Expressions.ExpressionHelper.AwaitValueTaskHelper[T](ValueTask`1 task)\r\n   at HotChocolate.Types.FieldMiddlewareCompiler.<>c__DisplayClass3_0.<<CreateResolverMiddleware>b__0>d.MoveNext()\r\n--- End of stack trace from previous location ---\r\n   at HotChocolate.Execution.Processing.ResolverTask.ExecuteResolverPipelineAsync()\r\n   at HotChocolate.Execution.Processing.ResolverTask.TryExecuteAsync()"
      }
    }
  ],
  "data": {
    "sentLogs": null
  }
}
  1. Without totalCount
query A {
  sentLogs {
    items {
      text
    }
   pageInfo {
     hasNextPage
     hasPreviousPage
   }
  }
}
{
  "data": {
    "sentLogs": {
      "items": [
        {
          "text": null
        },
        {
          "text": null
        },
        {
          "text": null
        },
        {
          "text": null
        },
        {
          "text": null
        },
        {
          "text": null
        },
        {
          "text": null
        },
        {
          "text": null
        }
      ],
      "pageInfo": {
        "hasNextPage": false,
        "hasPreviousPage": false
      }
    }
  }
}
@michaelstaib michaelstaib added 🌶 hot chocolate 🔍 investigate Indicates that an issue or pull request needs more information. labels Oct 19, 2020
@michaelstaib michaelstaib added this to To do in Backlog via automation Oct 19, 2020
@michaelstaib michaelstaib added this to the HC-11.0.0 milestone Oct 19, 2020
@michaelstaib michaelstaib moved this from 11.0.0 to review in Backlog Oct 27, 2020
@michaelstaib michaelstaib moved this from review to ready for next preview in Backlog Nov 4, 2020
@michaelstaib michaelstaib moved this from ready for next preview to current preview in Backlog Nov 5, 2020
@michaelstaib michaelstaib moved this from current preview to Done in Backlog Nov 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔍 investigate Indicates that an issue or pull request needs more information.
Projects
No open projects
Backlog
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants