sofa

sofa

  • Documentation
  • Github

›API

Introduction

  • Getting Started

Essentials

  • Queries
  • Mutations
  • Subscription

Recipes

  • OpenAPI (Swagger)

API

  • Nested data and Models
  • Using context
  • Using objects instead of IDs
  • Custom execute phase
  • Error Handling
  • Customize endpoint's HTTP Method

Using context

Here's how you provide a context to a GraphQL Schema.

Using a function

Sofa allows to build a context object through a factory function. You get an access to a request object through the req field.

api.use(
  '/api',
  useSofa({
    schema,
    async context({ req }) {
      return {
        req,
        ...yourContext,
      };
    },
  })
);

Using an object

You can also pass any data, directly, without using a function.

api.use(
  '/api',
  useSofa({
    schema,
    context: yourContext,
  })
);
Last updated on 3/9/2021 by renovate[bot]
← Nested data and ModelsUsing objects instead of IDs →
sofa
Twitter·Medium·Github
Copyright © 2021 The Guild