[lsp-server] Feature Request: Support for offline schema transforms
- Dominant language
- TypeScript
- Stars
- 16.9k
- Forks
- 1.9k
- Avg merge
- 22h 45m
- Merged PRs (30d)
- 70
Description
The API I've been working on has created some custom directives to make development easier, and usage of these relies on the `mapSchema` from `@graphql-tools/utils` to transform the schema.
I do realize that the extension can be configured to connect to the remote (localhost) api service to introspect the schema - however, that doesn't allow for proper Go-To Definition to work either - since the schema is split among a number of different files and introspection treats it as a single temporary large schema file.
I know this extension can be configured for glob pattern schema files `schema: '**/*.gql'` - and that works good for the Go-To definition, but errors due to the directives injecting extra fields onto the types.
Offline schema is also preferred since the developer doesn't actually have to spin up the api for it to start working.
A very small sample of what we are doing:
```gql
interface UserBase {
user_id: ID!
username: String!
first_name: String
middle_name: String
last_name: String
}
type User implements UserBase @inherits(field: "UserBase") {
created_at: DateTime
}
```
Our custom `@inherits` directive looks up the `UserBase` type, get the fields and merges them onto the type `User` that it is decorating - with the resulting type (once the API is running) looking like this:
```gql
"""@inherits from UserBase """
type User implements UserBase {
created_at: DateTime
"""@inherits from UserBase .user_id"""
user_id: ID!
"""@inherits from UserBase .username"""
username: String!
"""@inherits from UserBase .first_name"""
first_name: String
"""@inherits from UserBase .middle_name"""
middle_name: String
"""@inherits from UserBase .last_name"""
last_name: String
}
```
It would be awesome if there was some way to configure the extension (and therefore the language-server) by providing an extra script or function to introduce our own schema mapping so we can help the language server understand our custom directives.
If something like this were possible, an extra enhancement would be to allow the extensions customization to indicate the _original_ file/line that the Go-To definition would take when encountering these injected fields.
Contributor guide
Assessment
This issue has not been assessed yet.