Closed zhouzi closed 3 years ago
Sorry for the delay, I had to move onto something else. I needed this recently so I fixed a few things and published it under @zhouzi/apollo-server-integration-testing in order to test it properly on the codebase I am working on. Type checks started failing after upgrading, as expected. But once fixed it works like a charm ✨ We are using graphql-codegen
so here's an example of how it changed:
// before: no type check at all
const { data } = await query(GET_USER, { variables: { id: "some_id" } })
// data is properly typechecked, along with the variables
const { data } = await query<Pick<Query, "user">, QueryUserArgs>(GET_USER, { variables: { id: "some_id" } });
As mentioned previously, the type change is "breaking" in the sense that it requires users of the library to update their code if they are using TypeScript.
Hi @Zhouzi thanks for the update and for looping back to this one. I'd be happy to get this merged, but I think it should be a major version bump since it will be a breaking change for typescript users. What do you think?
Agreed, it should definitely be a major version 👍 I added it to the change log's vNext, let me know if there's anything else I can do to help.
Great, thanks again @Zhouzi! I have some pending work stuff to do today but I'll try to cut the major version later in the evening 👍
Looking forward to this 👍
Just published 3.0.0 with this change! Please let me know if you find any bugs. Thanks again for your contribution, @Zhouzi!
This PR adds tests (albeit pretty simple) and improves
TestQuery
's return value type.Prior to this PR, here's how a query's return value is typed:
Here's how it can be done with this PR:
It would be a breaking change though, as with those changes, the first example's return value would end up being typed as:
I will be testing this PR on our codebase to make sure it's working as expected.
Closes #9