Type Compatibility with Apollo Full Stack Example #4992
Unanswered
mikecfisher
asked this question in
General
Replies: 1 comment
-
@mikefisher84 you can use different values for |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Until recently I've yet to see a good example of unit testing resolvers in a TypeScript Apollo Server app.
I recently discovered Apollo's example repo where they have some nice patterns for unit, integration and e2e testing Apollo Server apps. Apollo Test Example
However in my application while the testing patterns work, it tends to throw many typescript errors.
Error 1:
This was fixed by turning setting
noSchemaStitching: false
thanks @dotansimha for this. Saw this in another issue.Error 2:
Cannot invoke an object which is possibly 'undefined'.ts
This is because the resolver type is returned as optional. I can "fix" this by turning:
avoidOptionals: true
but then I get more TypeScript errors in my app due to all resolvers being required.Error 3:
This is because I have a large context object, however the resolver only requires this one Product datasource.
I'm creating a mock datasource like this:
But because I'm not passing in the full context I get this TS error.
If anyone has any ideas on how to fix these issues that would be great. Because the patterns in Apollo's example repo are great and feel like they should be the canonical way to test Apollo Server apps. However its tough to do that with the way graphql-codegen generates it's types for me.
Beta Was this translation helpful? Give feedback.
All reactions