How to use the sofa-api.useSofa function in sofa-api

To help you get started, we’ve selected a few sofa-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aerogear / graphback / templates / apollo-rest-starter / src / index.ts View on Github external
async function start() {
  const app = express()

  app.use(cors())

  app.get("/health", (req, res) => res.sendStatus(200))

  const schema = makeExecutableSchema({
    typeDefs,
    resolvers,
    resolverValidationOptions: {
      requireResolversForResolveType: false
    }
  });

  app.use("/rest", useSofa({
    schema,
  }))

  // connect to db
  const client = await connect(config.db);

  const apolloConfig = {
    schema,
    context: async ({
      req
    }: { req: express.Request }) => {
      // pass request + db ref into context for each resolver
      return {
        req: req,
        db: client,
        pubsub

sofa-api

Create REST APIs with GraphQL

MIT
Latest version published 4 months ago

Package Health Score

80 / 100
Full package analysis

Popular sofa-api functions