Open kbrandwijk opened 6 years ago
Any idea how this would then work with js-only codebases? What would be the equivalent for the following:
Yes, in that case you can't strongly type that context
parameter, but setting it on the context would ideally provide IDE intellisense because the .d.ts file is present.
Would would you set the context type then?
When I use the javascript generated binding file, I still get intellisense support in VS code, even without a typings file (they added that in one of the recent releases). Do you still think this is needed @schickling?
Is that snippet vanilla JS? I'm wondering how ctx: Context
works?
No, this is the JS binding in a TS project, sorry... I'll retest with a full JS project.
.d.ts
files would be very useful
I can use typescript and webstorm recognises it, but it would be nice to just have the definitions
Creating a separate .d.ts
file isn't that difficult, the difficuly comes from the fact that .graphqlconfig
only has one output setting. My current idea is to add an optional typings
setting to the graphql-config extension (similar to package.json) that, when present, causes it to put the typings in a separate file. @schickling Do you agree with that solution?
@kbrandwijk can you show an example how that would look like?
extensions:
prepare-binding:
output: src/generated/prisma.ts
typings: src/generated/prisma.d.ts
generator: prisma-ts
If typings
is there, it will create two separate files, otherwise just one. This makes sure it is a non-breaking change, and anyone not changing their config will get the identical output to what they're getting now, which is very important I think.
Heya. I can try to have a stab at it, but unsure where to start, can you give me some pointers?
I want to generate the interfaces separately so they can be shared between clients/server. (https://github.com/KATT/shop/pull/35)
How come prisma bindings didn’t go on using + contributing to like gql2ts
underneath instead of writing your own lib for generating ts defs?
Was it considered? It seems well-maintained, well-tested, etc.
@KATT Because it solved only half of our goals, which was to both create type definitions, and also create a Binding class to use in your server.
For both js and ts generators, putting the type definitions in a separate
.d.ts
file helps with IDE tooling.