Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Convert to TypeScript #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

[WIP] Convert to TypeScript #5

wants to merge 1 commit into from

Conversation

philschatz
Copy link
Owner

@philschatz philschatz commented Apr 9, 2018

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant