// see https://graphql.org/learn/serving-over-http/#http-methods-headers-and-body private async Task <GraphQLHttpRequest> BuildGraphQLHttpRequestAsync(HttpContext httpContext) { GraphQLHttpRequest gqlHttpReq; var method = httpContext.Request.Method; switch (method) { case "GET": gqlHttpReq = BuildGetRequest(httpContext); break; case "POST": gqlHttpReq = await BuildPostRequestAsync(httpContext); break; default: throw new Exception($"Invalid Http method: {method}; expected GET or POST."); } // create internal request context gqlHttpReq.RequestContext = Server.CreateRequestContext(gqlHttpReq.Request, httpContext.RequestAborted, httpContext.User, null, gqlHttpReq); return(gqlHttpReq); }
// see https://graphql.org/learn/serving-over-http/#http-methods-headers-and-body private async Task <GraphQLHttpRequest> BuildGraphQLHttpRequestAsync(HttpContext httpContext) { GraphQLHttpRequest gqlHttpReq; var method = httpContext.Request.Method; switch (method) { case "GET": gqlHttpReq = BuildGetRequest(httpContext); break; case "POST": gqlHttpReq = await BuildPostRequestAsync(httpContext); break; default: throw new Exception($"Invalid Http method: {method}; expected GET or POST."); } // create internal request context gqlHttpReq.RequestContext = Server.CreateRequestContext(gqlHttpReq.Request, httpContext.RequestAborted, httpContext.User, null, httpContext); // Try retrieving VITA operation context. if (httpContext.Items.TryGetValue(OperationContextKey, out object opContext)) { gqlHttpReq.RequestContext.VitaOperationContext = opContext; } return(gqlHttpReq); }