Type-safe mocks, resolvers, and store #7480
Unanswered
aaronadamsCA
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
@graphql-tools/mock
should be able to consume types generated by GraphQL Codegen to provide fully type-safe signatures for mocks, resolvers, and the mock store.Mocks
The exported
IMocks
type doesn't seem to work correctly.We're using this
Mocks
type locally instead and it works pretty well, giving us type checking and autocomplete on our mock data:Resolvers
Mock resolvers differ from real resolvers in at least two ways:
source
parameter is always aRef
instead of a parent object.Ref
in place of a result object.We're using this
MockResolvers
type locally, it's far from perfect but it's a good start:Store
Right now the mock store is completely untyped, all of its get and set signatures use
unknown
. I think it should be possible to pass the generatedResolvers
type to create a fully-typed store.Beta Was this translation helpful? Give feedback.
All reactions