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.

Non-blocking Schema Initialization for ASP.net core middleware

See original GitHub issue

Is your feature request related to a problem? Please describe. I’m just started looking into this tool so perhaps I’m missing something, but it would be nice if there were the option to load the schema in a non-blocking when using the ASP.net core middleware.

Right now I’m having to do something like this to initialize the schema in Startup.cs:

public void ConfigureServices(IServiceCollection services) { ISchema schema = Schema.Create(File.ReadAllText(($"{env.ContentRootPath}/GraphQL/schema.graphql"))); services.AddGraphQL(schema); }

Describe the solution you’d like It would be nice if there were an alternative async lazy initialization. I imagine there could be performance downsides if requests come in before the application loads; however, this could be mitigated by using something like this (https://github.com/thomaslevesque/AspNetCore.AsyncInitialization) for those concerned about performance.

Describe alternatives you’ve considered

  • Not using the middleware and implementing async schema loading/the endpoint
  • Maybe this is possible and I’ve just overlooked something key

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
michaelstaibcommented, May 23, 2019

If you are on version 9 preview try the new schema builder:

SchemaBuilder.New()
    .AddDocumentFromString("type Query { ....")
    .BindResolver<MutationResolver>().To("Mutation")
    .BindResolver<QueryResolver>().To("Query")
    .Create();  
0reactions
michaelstaibcommented, Jun 14, 2020

This one is now implemented with the new configuration API on version 11.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Non-blocking Schema Initialization for ASP.net core ...
The schema binding itself does no IO work. So, it basically is only the ReadAllText. I think it becomes problematic with dependency injection ......
Read more >
Asynchronous initialization in ASP.NET Core, revisited
Two months ago I published a blog post about asynchronous initialization of an ASP.NET Core app using a custom middleware.
Read more >
Add custom middleware in ASP.NET Core application
Here, you will learn how to create and add your own custom middleware into the request pipeline of ASP.NET Core application. The custom...
Read more >
Session and state management in ASP.NET Core
Provides middleware for managing session state. To enable the session middleware, Program.cs must contain: Any of the IDistributedCache memory ...
Read more >
Non-linear middleware chains in ASP.NET Core - Michał Dudak
ASP.NET Core Middleware doesn't have to be chained one after another. This article present options we have to create non-linear middleware ...
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