Skip to content

Use Template Literal Types in TS 4.1 #158

Description

@acro5piano

In the following repository, it parses SQL into TypeScript type. No codegen tool is needed anymore.

https://github.com/codemix/ts-sql

The syntax should be like this:

// Query.ts

import { QueryFactory } from 'typed-graphqlify'

const schema = gql`
  type Query { 
    hello: String!
  }
`

export type Query<T> = QueryFactory<T, typeof schema>
// HelloQuery.ts

import { Query } from './Query'

const HelloQuery = gql`
  { hello }
`

type IHelloQuery = Query<typeof query>

// Equivalent to the following. Cool!
//
// type IHelloQuery = {
//   data?: { 
//     hello: string
//   }
// }

I think we can do the same thing in GrapQL.

I've started to work on this, will use next branch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions