sofa

sofa

  • Documentation
  • Github

›Recipes

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

OpenAPI (Swagger)

Thanks to GraphQL's Type System Sofa is able to generate OpenAPI (Swagger) definitions out of it. Possibilities are endless here. You get all the information you need in order to write your own definitions or create a plugin that follows any specification.

import { OpenAPI, useSofa } from 'sofa-api';

const openApi = OpenAPI({
  schema,
  info: {
    title: 'Example API',
    version: '3.0.0',
  },
});

app.use(
  '/api',
  useSofa({
    schema,
    onRoute(info) {
      openApi.addRoute(info, {
        basePath: '/api',
      });
    },
  })
);

// writes every recorder route
openApi.save('./swagger.yml');
Last updated on 3/9/2021 by renovate[bot]
← SubscriptionNested data and Models →
sofa
Twitter·Medium·Github
Copyright © 2021 The Guild