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
import{GRAPHQL_AUTH_MODE}from'@aws-amplify/api-graphql';import{API}from'aws-amplify';// I'd like to extend my TVariables, so I could pass in more variables, such as authMode.// Why not use a context? // Because different queries need to be called with different auth mode.// An example of what I WANT to doexportconstuseGraphQLApi=<TData,TVariablesextends{authMode: GRAPHQL_AUTH_MODE}>(query: string):
((variables?: TVariables)=>Promise<TData>)=>{returnasync(variables?: TVariables)=>{const{ authMode =GRAPHQL_AUTH_MODE.AWS_IAM, ...rest}=variables||{};constres=awaitAPI.graphql({query,variables: rest,authMode: authMode});returnresasany;};};
But it doesn't work. Because the generated types don't contain the "authMode" parameter and it gives a type error.
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
-
Hi.
I'm currently in a situation like this
But it doesn't work. Because the generated types don't contain the "authMode" parameter and it gives a type error.
Any ideas on how to build such fetcher?
Beta Was this translation helpful? Give feedback.
All reactions