Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support more than one distinct schema in one repository #278

Closed
mattddean opened this issue Apr 1, 2024 · 6 comments
Closed

Support more than one distinct schema in one repository #278

mattddean opened this issue Apr 1, 2024 · 6 comments

Comments

@mattddean
Copy link

I have two APIs I'd like to make requests to with gql.tada.

I'd love to see graphqlsp support reading from multiple schema files.

It's totally fine IMO to use a different "template" for each if that helps the LSP differentiate between the two schemas.

Example of what I'd like to put in my tsconfig.json file:

{
    ...
    "plugins": [
      {
        "name": "@0no-co/graphqlsp",
        "schema": "http://localhost:3001/graphql",
        "tadaOutputLocation": "../../packages/api/src/api1/schema.generated.d.ts",
        "template": "gql"
      },
      {
        "name": "@0no-co/graphqlsp",
        "schema": "http://localhost:3002/graphql",
        "tadaOutputLocation": "../../packages/api/src/api2/schema.generated.d.ts",
        "template": "graphql"
      }
    ],
    ...
}
@JoviDeCroock
Copy link
Member

JoviDeCroock commented Apr 1, 2024

Dupe #264 and #223

@mattddean
Copy link
Author

mattddean commented Apr 1, 2024

@JoviDeCroock I looked at that issue and I believe we're looking for two different things. I want to be able to differentiate between two entirely separate APIs. I don't want the types from all of the schemas to be concatenated into each other.

Unless I've misunderstood issue #264, the solution proposed wouldn't have a way to differentiate between the two schemas when writing a query.

@JoviDeCroock
Copy link
Member

Hmm, in that case I misunderstood in that case we might be missing some information here. Are you seeing both tadaOutputLocations being respected as a first case could be that TS does not support duplicate plugins being active. If that works you might be running into our default template tags, i.e. if you use graphqlSchema1 and graphqlSchema2 does it work?

@mattddean
Copy link
Author

mattddean commented Apr 1, 2024

Yes, both tadaOutputLocations are respected, but the LSP isn't designed to support this, per @kitten: https://discord.com/channels/1082378892523864074/1210514957863485460/1213265117576433705

I tried with two different template tags and the results were the same.

Side note: sorry to have missed discussion #223, that is a true duplicate of this request. Let's continue the discussion there, if you'd like.

@JoviDeCroock
Copy link
Member

Your case should work but not when your templates overlap with the default https://github.com/0no-co/GraphQLSP/blob/main/packages/graphqlsp/src/ast/templates.ts

@mattddean
Copy link
Author

Hmm, just tried with two different templates, neither of which being graphql or gql, and I seem to get the the same result: it uses the first plugin for typechecking and the second for VSCode autocompletion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants