prismake / typegql

Create GraphQL schema with TypeScript classes.
https://prismake.github.io/typegql/
MIT License
423 stars 21 forks source link

Duplex type #45

Closed capaj closed 6 years ago

capaj commented 6 years ago

I know you've said that you don't want to implement a Duplex type, but I'd like you to reconsider. GraphQL spec has good reasons not to do this-GraphQL raw schemas are mostly meant for consumption by machines. Explicitness and some repetition is perfectly fine there.

But in our code that we humans write and read this verbose explicit code is not always so great. We shouldn't force everyone to follow graphql spec in their own programming language. This library's API is not bound by the graphql spec. It's output is bound by it, but not it's client API. Making it easier to write a graphql API is what this library is all about for me. The minority of users of this lib who would want to define separate input and object types still can.

I've implemented just a simple POC which might still have some uncovered bugs, but I think it demostrates clearly that it's easily achieved.

codecov[bot] commented 6 years ago

Codecov Report

Merging #45 into master will decrease coverage by 1.71%. The diff coverage is 73.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #45      +/-   ##
==========================================
- Coverage   87.43%   85.71%   -1.72%     
==========================================
  Files          61       65       +4     
  Lines        1106     1197      +91     
  Branches      194      211      +17     
==========================================
+ Hits          967     1026      +59     
- Misses        138      170      +32     
  Partials        1        1
Impacted Files Coverage Δ
src/domains/inputObjectType/compiler/objectType.ts 76.66% <ø> (ø) :arrow_up:
src/domains/inputField/compiler/index.ts 91.66% <ø> (ø) :arrow_up:
src/domains/arg/compiler.ts 90.16% <ø> (ø) :arrow_up:
src/domains/field/compiler/index.ts 90.62% <ø> (ø) :arrow_up:
src/domains/inputField/compiler/fieldType.ts 64.28% <100%> (ø) :arrow_up:
src/domains/field/compiler/services.ts 88.88% <100%> (ø) :arrow_up:
src/domains/index.ts 100% <100%> (ø) :arrow_up:
src/services/utils/gql/types/resolve.ts 92.1% <100%> (ø) :arrow_up:
src/domains/duplexField/index.ts 57.69% <57.69%> (ø)
src/domains/duplexObjectType/error.ts 63.15% <75%> (ø)
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 432b507...e23b44b. Read the comment docs.

capaj commented 6 years ago

the solution of autocreating an input type when object type is used as an argument sounds much better than this. Closing and will try to implement it that way.