-
Notifications
You must be signed in to change notification settings - Fork 164
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
Add Azure Functions support #966
Conversation
src/Transports.AspNetCore/Extensions/GraphQLBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Ivan Maximov <sungam3r@yandex.ru>
Co-authored-by: Ivan Maximov <sungam3r@yandex.ru>
Co-authored-by: Ivan Maximov <sungam3r@yandex.ru>
Co-authored-by: Ivan Maximov <sungam3r@yandex.ru>
Co-authored-by: Ivan Maximov <sungam3r@yandex.ru>
I would keep naming as is to accent on Azure applicability. |
…erver into azure_functions
50/50 here, not sure. |
Codecov Report
@@ Coverage Diff @@
## master #966 +/- ##
==========================================
- Coverage 95.11% 92.71% -2.40%
==========================================
Files 42 44 +2
Lines 2087 2142 +55
Branches 359 364 +5
==========================================
+ Hits 1985 1986 +1
- Misses 59 113 +54
Partials 43 43
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
I'll do a separate PR after merging this so we can both review the alternative design. I'm 50/50 also. |
@sungam3r I added tests, documentation, and etc. Ready to complete review and merge. |
Please note that the GraphQL schema needs to be initialized for every call through | ||
Azure Functions, since it is a serverless environment. This is done automatically | ||
but will come at a performance cost. If you are using a schema that is expensive | ||
to initialize, you may want to consider using a different hosting environment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspected that the schema should be created every time so your note about overhead here
We could eliminate the need to register the middleware in DI, similar to how the UI action results work, but then there is a bit of startup overhead for each request. Not sure if this occurs anyway for azure functions or not, or which would be a better approach.
will not affect the overall costs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking the same thing. I think we will find that the alternative approach for Azure Functions is better overall.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible that if multiple calls are made in succession maybe then the schema would not need to be reinitialized.
But regardless, I looked at GraphQLHttpMiddleware and it seems that we can make some private readonly fields static anyway. At which point, initializing one class should have little effect on speed/memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will have any effect only if Azure Function environment does not unload entirely the whole app (dll/domain/process/whatever) from memory.
This PR adds support for Azure Functions. To use:
AddGraphQL
the same way as is done elsewhere.AddAzureFunctionsMiddleware()
within theAddGraphQL
callActionResult
:UI packages add an
ActionResult
to easily use them with controller projects or Azure Functions.Notes
.AddAzureFunctionsMiddleware<T>()
andreturn new AzureGraphQLActionResult<T>()
..AddAzureFunctionsMiddleware<T>(opts => { });
Comments / questions:
AzureGraphQLActionResult
is not specific to Azure Functions. It could be used for ASP.NET Core also, but it is harder to use and inferior to the middleware technique we already support. In any case, we could drop the "Azure Functions" naming from the new classes/interfaces and call it something likeGraphQLExecutionActionResult
Todo: