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

Auto-generate TypeScript typings #1

Open
rubensworks opened this issue May 13, 2019 · 1 comment
Open

Auto-generate TypeScript typings #1

rubensworks opened this issue May 13, 2019 · 1 comment

Comments

@rubensworks
Copy link
Owner

When given a GraphQL-LD query, it should be possible to auto-generate TypeScript typings.

For example:

query MyQuery @single(scope: all) {
  graph
  ... on Collection {
    subset(_:PAGE)
    search @plural {
      template
      variableRepresentation
      mapping @plural {
        variable
        property
      }
    }
  }
}

Example of typings:

interface MyQuery {
  graph: string;
  search: MyQuery_search[];
}
interface MyQuery_search {
  template: string;
  variableRepresentation: string;
  mapping: MyQuery_search_mapping[];
}
interface MyQuery_search_mapping {
  property: string;
  variable: string;
}
@shnydercom
Copy link

Hi, this is a very interesting project! There might be options to piggyback on developments around generators:

The way graphql-code-generator generates typings/queries/hooks and what not is either by a schema file or a live endpoint's introspection. If it's possible to generate an introspection for a sparql endpoint, all existing generators could use that in turn. Here's a generator for an introspection file

Another problem is very custom graphql endpoints, often with different maturity levels of individual queries and mutations.
I believe in order to get people to use global identifiers, their domain model has to have some translation/transformation to global models as well. Graphql in practice is often used like REST, and often tree models instead of graphs, especially towards the beginning of projects. To keep a graph database's model and a graphql schema in sync, there's a project from neo4j that generates the graph's relationships as a result of a graphql schema with annotations. Maybe this can help conceptually, here's how relationships are expressed there, queries and mutations are auto-generated and resemble their query language.

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

No branches or pull requests

2 participants