0no-co / gql.tada

🪄 Magical GraphQL query engine for TypeScript
https://gql-tada.0no.co
MIT License
2.45k stars 36 forks source link

feat(cli-utils): Implement multi-schema support for CLI commands #261

Closed kitten closed 2 months ago

kitten commented 2 months ago

Resolves #248 Related to #257

This implements multi-schema support, as per the RFC, in the CLI. This, together with https://github.com/0no-co/GraphQLSP/pull/303 fully resolves the RFC and implements true multi-schema support.

A given tsconfig.json with the plugin configuration can now set up multiple schemas:

{
  "compilerOptions": {
    "plugins": [
      {
        "name": "@0no-co/graphqlsp",
        "schemas": [
          {
            "name": "pokemon",
            "schema": "./schema.graphql",
            "tadaOutputLocation": "./src/graphql-env.d.ts",
            "tadaTurboLocation": "./src/graphql-cache.d.ts",
            "tadaPersistedLocation": "./src/persisted.json"
          },
          // ...
        ]
      }
    ]
  }
}

These can be used by instantiating them with initGraphQLTada via the output file (as specified by tadaOutputLocation). The new configuration is fully validated (as can be seen when running gql.tada doctor.

[!WARNING] Whenever a command accepts an --output argument, this is now unsupported by the CLI command in favour of clear configuration options (i.e. tadaOutputLocation, tadaTurboLocation, and tadaPersistedLocation) This is except for the generate schema command, with which multiple schema requires the --output option now.

changeset-bot[bot] commented 2 months ago

🦋 Changeset detected

Latest commit: cb56be81a0fde35150ef5a504271fea1901ee62f

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR