0no-co / gql.tada

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

Allow define multiple plugin with separated `-env.d.ts` #195

Closed tianyingchun closed 4 months ago

tianyingchun commented 4 months ago

Describe the bug

we can via multiple plugins:

  "plugins": [
      {
        "name": "@0no-co/graphqlsp",
        "schema": "http://localhost:9001/shop-api",
        "tadaOutputLocation": "./e2e/graphql/graphql-shop-env.d.ts"
      },
      {
        "name": "@0no-co/graphqlsp",
        "schema": "http://localhost:9001/admin-api",
        "tadaOutputLocation": "./e2e/graphql/graphql-admin-env.d.ts"
      }
    ]

it will correct generated graphql-shop-env.d.ts and graphql-admin-env.d.ts

but cause of each -env.d.ts have the same declare module will typings merge via interface setupSchema

declare module 'gql.tada' {
  interface setupSchema {
    introspection: introspection
  }
}

if we want to create two individual grapql

import { initGraphQLTada } from '@semic/testing';
import type { introspection } from './graphql-admin-env.js';

export const graphql = initGraphQLTada<{
  introspection: introspection;
}>();
import { initGraphQLTada } from '@semic/testing';
import type { introspection } from './graphql-shop-env.js';

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

only one is valid it's conflict , how we can resolve this?

Reproduction

image

gql.tada version

"gql.tada": "1.4.3",

Validations

kitten commented 4 months ago

Duplicate of https://github.com/0no-co/gql.tada/issues/190