Replies: 1 comment 2 replies
-
TypeGraphQL produces standard GraphQL schema. You can you all the tools for GraphQL for frontend to have typesafe queries, like graphql code generator. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm developing an app that uses type-graphql + apollo server on the backend, and the apollo client + react for the frontend. Right now I have my repo split into 3 packages: client, server, and schema.
Server imports the schema, creates the resolver for it, and then does a
buildSchema()
for theApolloServer
.On the client side, I import just the schema as types, and pass them as the generic type to
ApolloClient.useQuery<Type>()
.This generally seems to work well. Is there a different or better way to do things?
One big problem I've noticed (though maybe its more specific to Apollo than sharing the schema), is that the type returned from
useQuery
is ignorant of the actual query itself. So if my type/schema isand my query is
The returned
data
object fromuseQuery()
only actually has theid
andtitle
properties, but because the schema type hasdescription
creationDate
andingredients
as well, typescript things that those exist ondata
even though they don't. Is there any way to address this?Beta Was this translation helpful? Give feedback.
All reactions