Skip to content

Thinkmill/graphql-ts

main
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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

graphql-ts

@graphql-ts/schema is a thin wrapper around GraphQL.js providing type-safety for constructing GraphQL Schemas while avoiding type-generation, declaration merging and decorators.

import { graphql } from "@graphql-ts/schema";
import { GraphQLSchema, graphql as runGraphQL } from "graphql";

const Query = graphql.object()({
  name: "Query",
  fields: {
    hello: graphql.field({
      type: graphql.String,
      resolve() {
        return "Hello!";
      },
    }),
  },
});

const schema = new GraphQLSchema({
  query: Query.graphQLType,
});

runGraphQL({
  source: `
    query {
      hello
    }
  `,
  schema,
}).then((result) => {
  console.log(result);
});