Replies: 1 comment
-
Similar to: https://github.com/dotansimha/graphql-code-generator/issues/6014 |
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
Uh oh!
There was an error while loading. Please reload this page.
-
Maybe i'm totally mistaken about this or i'm missing something here.
i have a query:
and i'm trying to call the query passing the userId from a state, which can be
undefined
(have type ofstring | undefined
)So my thoughts here for this error is that i should be able to make the whole variables object optional so i can pass the variables after checking that they are actually available
I found the only way to get over this is make the
$userId
in my query an optional variable (remove the!
) which feels kinda "hacky" to me, I still want the variables to be typed and passed with the right restrictions toward what is optional and what is required, but at the same time i wanna be able (NOT-to-pass)/(condition) the variables object as a whole, in case i'm waiting for some other data/state before calling the query.My thoughts is that maybe not passing the variable object at all can prevent the query from being executed/called until the variables object is passed (with all the required properties as they will be typed as specified in the gql query operation).
i checked
@graphql-codegen/typescript-react-query
for an option maybe to enable that, and couldn't find any. now i'm thinking maybe it can an optional thing to enable/disable (the variables object being always optional)?Or maybe i'm missing another way to do this other of what i mentioned. any help/thoughts are appreciated
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions