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
Sometimes it would we useful to validate response type. The function should also give a way to transform the validated type:
import{getUserOrThrow}from'@/src/auth.js';import{createResolvers}from'@/src/axolotl.js';import{GraphQLError}from'graphql';exportconstMutation=createResolvers({Mutation: {public:()=>{return{}},user:async([,,context],args,validate)=>{constauthHeader=context.request.headers.get("Authorization")if(!authHeader)thrownewGraphQLError("You must be logged in to use this resolver")returnvalidate(getUserOrThrow(authHeader))}},})
This should be identity function only used for type check without real validation of response only to help developer experience
import{getUserOrThrow}from'@/src/auth.js';import{createResolvers}from'@/src/axolotl.js';import{GraphQLError}from'graphql';exportconstMutation=createResolvers({Mutation: {public:()=>{return{}},user:async([,,context],args,validate)=>{constauthHeader=context.request.headers.get("Authorization")if(!authHeader)thrownewGraphQLError("You must be logged in to use this resolver")returnvalidate<ReturnType<typeofvalidate>&{smth:string}>(getUserOrThrow(authHeader))}},})
The text was updated successfully, but these errors were encountered:
Sometimes it would we useful to validate response type. The function should also give a way to transform the validated type:
This should be identity function only used for type check without real validation of response only to help developer experience
Overloading would look like that
The text was updated successfully, but these errors were encountered: