Skip to content

dotansimha/graphql-typed-ast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

graphql-typed-ast

Experimental TypeScript type-based parser for GraphQL.

This repo is for experimental TypeScript type-system based parser for GraphQL, for creating a real time resolvers-signature based on GraphQL SDL.

It uses a custom alpha version of TypeScript from this PR.

Goals

  • GraphQL Lexer
  • GraphQL Document Parser

Example

The goal of this experiment is to allow this:

const ast = `
       type Query { user(id: ID!): User! }
       type User { id: ID!, name: String! }
    `;

const resolvers: ResolverFor<
   typeof ast,
    { User: UserModel },
    ContextType
  > = {
  Query: {
    user(parent, { id }, context) => {
       // parent is null, id is string | number, context is ContextType, expected return type is `UserModel` 
    } 
  },
  User: {
    name: (parent, args, context) => {
      // parent is UserModel, args is {}, context is ContextType, expected return type is `string`
    }
  }
};

About

Experimental TypeScript type-based parser for GraphQL

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •