graphql-zeus
graphql-zeus copied to clipboard
typedGql not type safe?
I'm using zeus with apollo and it seems that I can pass any arbitrary key to typedGql
which will compile but end up as a 400. Am I missing something that makes typedGql
fully type safe?
--
For example, I have a query like this:
const plants = typedGql("query")({
plants: {
__typename: true,
id: true,
createdAt: true,
description: true,
hello: true
}
})
And a schema like this:
### This file was generated by Nexus Schema
### Do not make changes to this file directly
"""
A date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the `date-time` format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar.
"""
scalar DateTime
type Plant {
createdAt: DateTime!
description: String!
id: Int!
url: String!
}
type Query {
plants: [Plant!]!
}
Notice the hello: true
line in the query. This typechecks yet causes a 400 on the backend since hello is unexpected. How can I make this typesafe and reject hello
?
What's even stranger is if I remove the id
field then it no longer typechecks...
This compiles:
This does not:

I have an idea how to fix that but I already tried 999 times so maybe
almost fixed
Any progress on this?
@aexol might this approach help somehow? https://stackoverflow.com/a/57117594
I'm also interested in type safety for typedGql. On version 5.3.1 I'm still able to request an arbitrary property without errors. Is this issue actually completed/resolved or is it just closed?
I don't believe it got resolved, I was just cleaning up issues I've opened that seem stale.
I also commented on https://github.com/graphql-editor/graphql-zeus/issues/232 Seems like these issues are (almost?) identical. Both these issues were closed with the #381 pull request.
I'm still able to request arbitrary fields with the most recent version 5.3.2 Is anyone able to confirm that this PR actually solved the issue? and if so then can i get a working sample project?