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

Creating a GraphQL endpoint #1

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

Conversation

HaMster21
Copy link
Owner

No description provided.

GraphQL has just a single endpoint, reacting to get and post requests. This endpoint later performs the request parsing and delegates work to the schema classes. We'll get to that
We need a graphql library to parse requests and route them classes to handle them. We'll use HotChocolate for that.
In order to use dependency injection and configure HotChocolate, we use a functions startup class. It works like a regular startup class you'd write for asp.net and asp.net core, though it's autogenerated if not declared explicitly.

HotChocolate uses the IoC capabilities of asp.net core to configure and use services. They are injected into the resolvers so you can use them
The most basic type of every graphql schema is a type representing queries. This type exposes fields to query data from the API.

To get started, we creat a field called greeting, returning a greeting string. Next up we'll register the query type with HotChocolate and use it within our graphql endpoint
This step is the same on Azure Functions and in aps.net core projects.
In order to process requests in graphql, we need a query executor. Function level dependency injection, to my knowledge, is not yet working in Azure Functions, so we'll use constructor injection instead.

We're not yet parsing requests in graphql, this will be the next step.
When receiving graphql requests, we only know about the query and the variables part. Operation names don't matter here. So we forget about them.

HotChocolate oddly only works in version 10.0.1 with Azure functions, so we adapt that dependency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant