Skip to main content
Deno 2 is finally here 🎉️
Learn more

gql_tools

CI Status

GraphQL Tools port for Deno

Usage

I strongly recommend importing only the module you need using it’s dedicated mod.ts file.

import { mergeDeep } from "https://deno.land/x/gql_tools@v7.0.5+4/lib/utils/mod.ts";
import { makeExecutableSchema } from "https://deno.land/x/gql_tools@v7.0.5+4/lib/schema/mod.ts";

Example

import {
  IResolvers as Resolvers,
  ITypeDefinitions as TypeDefinitions,
} from "https://deno.land/x/gql_tools@v7.0.5+4/lib/utils/mod.ts";
import { makeExecutableSchema } from "https://deno.land/x/gql_tools@v7.0.5+4/lib/schema/mod.ts";

import { GraphQLSchema } from "https://cdn.skypack.dev/graphql@15.5.0?dts";

const users = [
  { id: 1, name: "Ryan" },
  { id: 2, name: "Luca" },
];

const typeDefinitions: TypeDefinitions = `
  type User {
    id: Int!
    name: String
  }
  
  type Query {
    user(id: Int!): User
  }
`;

const resolvers: Resolvers = {
  Query: {
    user: (_, { id }) => users.find((user) => user.id === id),
  },
};

const executableSchema: typeof GraphQLSchema = makeExecutableSchema({
  typeDefs: typeDefinitions,
  resolvers,
});

Tags and module versions

Tags will mirror the graphql-tools module. For specific module versions please reference lib/VERSIONS.md.

Contributing

Please refer to the Deno Style Guide as well as the Conventional Commits spec.