0no-co / GraphQLSP

TypeScript LSP plugin that finds GraphQL documents in your code and provides diagnostics, auto-complete and hover-information.
https://gql-tada.0no.co
MIT License
332 stars 13 forks source link

Schema name is not computed when using multiple schemas #332

Closed felamaslen closed 1 month ago

felamaslen commented 1 month ago

Steps to reproduce:

  1. Define in tsconfig.json
{
  "plugins": {
    "name": "@0no-co/graphqlsp",
    "schemas": [
      {
        "name": "schema-a",
        "schema": "./src/schema-a.graphql",
        "tadaOutputLocation": "./src/types/graphql-env-a.d.ts",
        "tadaPersistedLocation": "persisted-a.json"
      },
      {
        "name": "schema-b",
        "schema": "./src/schema-b.graphql",
        "tadaOutputLocation": "./src/types/graphql-env-b.d.ts",
        "tadaPersistedLocation": "persisted-b.json"
      }
    ]
  }
}
  1. Define schema and document
// src/graphql-a.ts
import { initGraphQLTada } from 'gql.tada'
import type { introspection } from './types/graphql-env-a';

export const graphql = initGraphQLTada<{
  introspection: introspection;
}>()

// src/myDocument.ts
import { graphql } from './graphql-a'

export const MyDocument = graphql.persisted(
  'sha256:abc123',
  graphql(`
    query My {
      myField
    }
  `),
);
  1. Run npx gql.tada generate-persisted

Expected behaviour

An output file is created at persisted-a.json, containing your document

Actual behaviour

No output file is created