convoyinc / ts2gql Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
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.
Why does it have this behavior? Can we remove it?
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
}
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?
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.