Skip to main content
Module

x/graphql_http/deps.ts>createResponse

GraphQL client and handler compliant with GraphQL over HTTP specification
Latest
function createResponse
import { createResponse } from "https://deno.land/x/graphql_http@1.0.0-beta.20/deps.ts";

Create a GraphQL-over-HTTP compliant HTTP Response from an HTTP Request.

Examples

Example 1

import { createResponse } from "https://deno.land/x/gaphql_response@$VERSION/mod.ts";
import { buildSchema } from "https://esm.sh/graphql@$VERSION";

const url = new URL("http://localhost/graphql");
const query = `query Test { greet }`;
url.searchParams.set("query", query);
const qqlRequest = new Request(url);

const schema = buildSchema(`type Query {
  greet: String
}`);
const response = await createResponse(qqlRequest, {
  schema,
  rootValue: {
    greet: () => "hello world!",
  },
});