INNER CODE UNIT · TypeScript

createResolvers

cloudflare/workers-graphql-server · src/resolvers.ts:5

const createResolvers = (context: Context): Resolvers<any> => {
  return {
    Mutation: {
      add: async (_parent, { numberOne, numberTwo }, { cache }) => {
        return numberOne + numberTwo
      },
    },

    Query: {
      movies: async () => {
        // You can access the context object to access any
        // environment variables, bindings, or other data
        // that you need to resolve your query.
        const _envKey = context.env.ENV_KEY
        const _userId = context.req.header("x-user-id")

        // You can bind other services in any resolver function
        // This allows you to connect any Workers services, databases,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…