All Projects → dotansimha → graphql-typed-ast

dotansimha / graphql-typed-ast

Licence: MIT License
Experimental TypeScript type-based parser for GraphQL

Programming Languages

typescript
32286 projects

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`
    }
  }
};
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].