Skip to content

A graphql http server for deno. Built on top of deno http server! 🦕

License

Notifications You must be signed in to change notification settings

TdfGomes/graphql4deno

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Graphql for Deno

Is very tiny and simple graphql http server built on top of Deno http module using some GraphQL utilities.

My goal with this was to have a simple dedicated http server to run GraphQL, no router, midllewares or..., something else. Just your schema and a http server.

This is heavily on development so the design and some decisions can change, still in progress...

How to use

import graphqlHttp from 'https://raw.githubusercontent.com/TdfGomes/graphql4deno/master/mod.ts'

import { 
  GraphQLSchema,
  GraphQLObjectType,
  GraphQLString } from "https://cdn.pika.dev/graphql@^15.0.0";

const schema = new GraphQLSchema({
  query: new GraphQLObjectType({
    name: "Query",
    fields: {
      greeting: {
        type: GraphQLString,
        resolve: (_obj, _args, context) => {
          return "Hello world";
        },
      },
    },
  }),
});

graphqlHttp({ port: 8080 }, "/graphql", { schema });

You can also do like this:

import graphqlHttp from 'https://raw.githubusercontent.com/TdfGomes/graphql4deno/master/mod.ts'
import { makeExecutableSchema } from "https://raw.githubusercontent.com/TdfGomes/graphql4deno/master/deps.ts";

const schema = makeExecutableSchema({
  typeDefs: `
    type Query {
      greeting: String
    }
  `,
  resolvers: {
    Query: {
      greeting: () => "Hello World",
    },
  },
});

graphqlHttp({ port: 8080 }, "/graphql", { schema });

or even like this:

import graphqlHttp from 'https://raw.githubusercontent.com/TdfGomes/graphql4deno/master/mod.ts'
import gql from "https://raw.githubusercontent.com/davidmwhynot/graphql-tag-deno/master/mod.ts";

const schema = gql`
	type Query {
     greeting: String
  }
`;

const resolvers = {
  Query: {
    greeting: () => "Hello World",
  },
}

graphqlHttp({ port: 8080 }, "/graphql", { schema, resolvers });

To run this from the you will need to use the allow-net flag (e.g deno run --allow-net example)


TODO

  • Error Handling
  • Add tests !!!
  • CORS
  • Improve Typescript
  • Add Graphql Subscriptions
  • 🤔

For sure this list will be bigger. If you see a bug or wanted to see an extra feature here open an issue or a pull request. I will be more than happy to have help.


Thank you

About

A graphql http server for deno. Built on top of deno http server! 🦕

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published