Platformatic v0.18.0 - GraphQL and OpenAPI support for Service, automatic config update, and many more fixes

Matteo CollinaMatteo Collina
3 min read

Hey Folks, we have been working hard in the last week to help reduce friction while building backend development. Unfortunately, this has led to a breaking change.

In Platformatic DB, you used to write:

{
  "core": {
    "connectionString": "..."
  }
}

Now you should write instead:

{
  "db": {
    "connectionString": "..."
  }
}

We made this change to better support Platformatic Service. However, you would not have to make any changes as your config file will automatically update while loading.

OpenAPI and GraphQL support for Platformatic Service

Platformatic Service can be configured to automatically expose OpenAPI and GraphQL schemas by providing the following configuration:

{
  "service": {
    "graphql": true,
    "openapi": true
  }
}

A complete set of options is also available! Make sure to check the configuration docs as well as @fastify/swagger and Mercurius.

This feature was implemented in #783

Automatic platformatic update

In version v0.17.0, we introduced a new platformatic upgrade command to allow you to upgrade to the latest configuration format easily. This same behavior is now applied whenever you start Platformatic DB or Platformatic Service, so you would not miss an update.

This feature was implemented in #784

TypeScript template for Platformatic Service

Platformatic Service now has its own typescript generator in npx create-platformatic@latest:

import { FastifyInstance, FastifyPluginOptions } from 'fastify'

export default async function (fastify: FastifyInstance, opts: FastifyPluginOptions) {
  fastify.get('/', async (request, reply) => {
    return { hello: fastify.example }
  })
}

This change was implemented by @dongheeleeme in [#757}(https://github.com/platformatic/platformatic/pull/757).

OpenAPI configuration

Platformatic DB and Platformatic Service now allows you to completely configure the OpenAPI schema:

  {
    "db": {
      ...
      "openapi": {
        ...
        "security": [{ "bearerAuth": [] }],
        "components": {
          "securitySchemes": {
            "bearerAuth": {
              "type": "http",
              "scheme": "bearer",
              "bearerFormat": "JWT"
            }
          }
        }
      }
    }
  }

This feature was implemented by @rozzilla in #779 and #785

Other fixes

  • Add more Fastify options to the server schema by @abdelrazzaq-dev in #738
  • Fix version dependent test in #761
  • metaconfig: update README code snippet by @cjihrig in #762
  • chore(service): Improve error message by @rozzilla in #765.
  • fix(tests): TypeScript config error by @rozzilla in #763
  • fix(docs): Issue #766 by @rozzilla in #767
  • docs: fix typo in guide for prisma database provider init option by @dmateiu in #768
  • feat: add config option for type generation target directory by @dmateiu in #769
  • Support directories in paths when using plugins by in #774.
  • Ensure create-platformatic always generate valid config by in #778.
  • set additionalProperties: false for config schema in #781
  • docs(contributing): Add troubleshooting guideline by @rozzilla in #787.

New Contributors

  • @dmateiu made their first contribution in #768
  • @dongheeleeme made their first contribution in #757
0
Subscribe to my newsletter

Read articles from Matteo Collina directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Matteo Collina
Matteo Collina