Git Product home page Git Product logo

ts2gql's Issues

Support generics and/or overrides.

Currently the following code will error with Error: Don't know how to handle AnyKeyword nodes:

// Foo.ts
export interface Foo {
  prop:any;
}

// schema.ts
import Foo from './foo';

export interface Bar extends Foo {
  prop:SomeConcreteType;
}

The expectation is that the GQL would contain the type:

type Bar {
  prop: SomeConcreteType
}

Alternatively the source code could be written:

// Foo.ts
export interface Foo<T> {
  prop:T;
}

// schema.ts
import Foo from './Foo';
 
export interface Bar extends Foo<SomeConcreteType>;

And that would result in the same output.

Support complex values for enums

The following code will produce invalid GQL:

interface Foo {
  export enum FooEnums {
    ONE = <any>'ONE',
    TWO = <any>'TWO',
    THREE = <any>'THREE',
  }

  export enum BarEnums {
    ONE = FooEnums.ONE,
    TWO = FooEnums.TWO,
  }
}

The GQL produced will be something like:

enum FooEnums {
  ONE
  TWO
}

enum BarEnums {
  FooEnums.ONE
  FooEnums.TWO
}

This is invalid. The code generation should produce the expected:

enum FooEnums {
  ONE
  TWO
}

enum BarEnums {
  ONE
  TWO
}

Support TypeScript >= 2.1

I am unable to get this to work under Windows 10. Running ts2gql input.ts using the sample input.ts file in the README produces the following output:

scalar Date

Any recommendations?

Support for GraphQL Required

I am opening a new issue since the other one (#4) is old and I haven't received any response in the discussion.
ts2gql is great but there are a lot of features of the GraphQL SDL that it does not support yet. Required is an essential feature and it would be great to exist support from the original repo.

I believe the most correct approach would be to create a NonNull node as a Wrapping Type and make everything required by default. This combines with the specification of TypeScript that declaring a function parameter requires the function to have this parameter and declaring an interface property requires it's not undefined (unless stated). Unions with null and undefined and ? marks would mark it as not required.

I'm up to implement this feature and submit a PR

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.