graphiql
graphiql copied to clipboard
[lsp-server] Custom Template Tag Literal Names
Current Behavior (if applicable)
From these code snippets:
- https://github.com/graphql/graphiql/blob/57b5fcd8749bd1c54f4a6a04a9ab07316fd05e71/packages/graphql-language-service-server/src/findGraphQLTags.ts#L286
- https://github.com/graphql/graphiql/blob/57b5fcd8749bd1c54f4a6a04a9ab07316fd05e71/packages/graphql-language-service-server/src/parseDocument.ts#L58
Looks like the set of template tag literals that the LSP searches for are hard-coded to a default set of tags.
Desired Behavior
I have a project using the GraphQL Codegen client-preset
where there are multiple roles by which one can query the same GraphQL API. Different roles get different sets of the GraphQL schema. No problem generating separate schema introspection files for each role.
But I'd like to configure the GraphQL LSP/VSCode plugin to use different schemas for different template tags in the same codebase, e.g.
const someAdminQuery = adminGql`
query GetAdminStuff {
# This is fine
admin_stuff {
// ...
}
}
`;
const someUserQuery = userGql`
query GetUserStuff {
# This should show an error
admin_stuff {
// ...
}
# This is fine
user_stuff {
// ...
}
}
`;
Or maybe there's a better way to achieve this while maintaining the colocated queries in application code? Thanks!
PRs welcome!
If you find a way to solve this problem by modifying the code in either the source or the distributed code, we are more than happy to accept enhancement requests as PRs!
Not sure I actually understand enough to do this efficiently, but I can try,.