Skip to content

cvng/deno_graphql

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Deno GraphQL

GraphQL HTTP middlewares for Deno server frameworks.

Setup with oak

import { Application, Context, Router } from "https://deno.land/x/oak/mod.ts";
import {
  gql,
  graphqlHttp,
  makeExecutableSchema,
} from "https://deno.land/x/deno_graphql/oak.ts";

const typeDefs = gql`
  type Query {
    hello: String
  }
`;

const resolvers = {
  Query: {
    hello: () => "Hello world!",
  },
};

const context = (context: Context) => ({
  request: context.request,
});

const schema = makeExecutableSchema({ typeDefs, resolvers });

const app = new Application();
const router = new Router();

router.post("/graphql", graphqlHttp({ schema, context }));

app.use(router.routes());

await app.listen({ port: 4000 });

Setup with abc

import { Application, Context } from "https://deno.land/x/abc/mod.ts";
import {
  gql,
  graphqlHttp,
  makeExecutableSchema,
} from "https://deno.land/x/deno_graphql/abc.ts";

const typeDefs = gql`
  type Query {
    hello: String
  }
`;

const resolvers = {
  Query: {
    hello: () => "Hello world!",
  },
};

const context = (context: Context) => ({
  request: context.request,
});

const schema = makeExecutableSchema({ typeDefs, resolvers });

const app = new Application();

app.post("/graphql", graphqlHttp({ schema, context }));

app.start({ port: 4000 });

Setup with attain

import { App, Request } from "https://deno.land/x/attain/mod.ts";
import {
  gql,
  graphqlHttp,
  makeExecutableSchema,
} from "https://deno.land/x/deno_graphql/attain.ts";

const typeDefs = gql`
  type Query {
    hello: String
  }
`;

const resolvers = {
  Query: {
    hello: () => "Hello world!",
  },
};

const context = (request: Request) => ({
  request: request,
});

const schema = makeExecutableSchema({ typeDefs, resolvers });

const app = new App();

app.post("/graphql", graphqlHttp({ schema, context }));

app.listen({ port: 4000 });

About

GraphQL HTTP middlewares for Deno server frameworks.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published