You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're introducing union and interfaces in our GraphQL API to unleash its true power 😄
I'm wondering how people are handling union and interfaces in their typical event handlers on the frontend in the context of TypeScript and graphql-codegen.
Right now I'm doing it "raw", just switching over the __typename values :
onClick={async()=>{const{ data }=awaitcreateTask({input: {name: "hello"}});switch(data?.createTask?.__typename){case"CreateTaskErrors":
for(consterrorofdata.createTask.errors){switch(error.__typename){case"InputValidationError":
// do something with error.fieldErrorsbreak;case"TaskAlreadyExists":
// do something with error.messagebreak;}}break;case"TaskCreated":
// do something with data.createTask.taskbreak;}
I'm wondering if they are codegen plugins or helpers that I can use to make this even simpler? How are you dealing with such structures? 😄
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello community!
We're introducing union and interfaces in our GraphQL API to unleash its true power 😄
I'm wondering how people are handling union and interfaces in their typical event handlers on the frontend in the context of TypeScript and graphql-codegen.
Right now I'm doing it "raw", just switching over the
__typename
values :I'm wondering if they are codegen plugins or helpers that I can use to make this even simpler? How are you dealing with such structures? 😄
Beta Was this translation helpful? Give feedback.
All reactions