project-bot icon indicating copy to clipboard operation
project-bot copied to clipboard

[WIP] Convert to TypeScript

Open philschatz opened this issue 7 years ago • 0 comments

In order to switch to TypeScript, GraphQL responses should also be strongly typed.

This uses GitHub's GraphQL Schema combined with a GraphQL Query to produce a TypeScript definition of the response.

See ./data/README.md for instructions on updating the Schema.

Run node ./data/build-from-query.js to generate the TypeScript definition files.

Example

Given the following GraphQL Query:

query getCardAndColumnAutomationCards($url: URI!) {
  resource(url: $url) {
    ... on Issue {
      projectCards(first: 10) {
        nodes {
          id
          url
          column {
            name
            id
          }
        }
      }
    }
  }
}

It generates a TypeScript definition like the following:

export interface GetCardAndColumnAutomationCardsInput {
  url: any;
}

export interface SelectionOnColumn {
  name: string;
  id: string;
}

export interface SelectionOnNodes {
  id: string;
  url: any;
  column: SelectionOnColumn | null;
}

export interface SelectionOnProjectCards {
  nodes: Array<SelectionOnNodes | null> | null;
}

export interface IFragmentSpreadOnIssue {
  projectCards: SelectionOnProjectCards;
}

export interface GetCardAndColumnAutomationCards {
  resource: Partial<IFragmentSpreadOnIssue> | null;
}

TODO

  • [x] create TypeScript definitions for GraphQL responses based on the Schema
  • [ ] convert the JavaScript files

philschatz avatar Apr 09 '18 08:04 philschatz