Open devkral opened 4 years ago
this only happens with the validate command.
You can tell custom directives with local schema. see https://github.com/Quramy/ts-graphql-plugin#localschemaextensions
I've tried defining a custom schema directive that way, and I'm receiving this error:
Schema build error: 'Directive "@client" already exists in the schema. It cannot be redefined.
Directive "@batch" already exists in the schema. It cannot be redefined.'
I think it could be because the directive exists in the introspection query result as a type. Here's my set-up:
schema.json
:
{
"__schema": {
// ...
"types": [
{
"name": "batch",
"description": null,
"isRepeatable": false,
"locations": [
"QUERY"
],
"args": [
{
"name": "argument",
"description": null,
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
]
}
]
}
}
local-extensions.graphql
:
directive @batch(argument: String) on QUERY
project-file.ts
:
export const DECORATE_ALBUM_GROUPS = gql`
query QueryName($ids: [String!]!) @batch(argument: "id") {
//...
}
tsconfig
:
{
// ...
"compilerOptions": {
"plugins": [
{
"name": "ts-graphql-plugin",
"schema": "schema.json",
"localSchemaExtensions": ["local-extensions.graphql"],
"tag": "gql",
"typegen": {
"addons": ["ts-graphql-plugin/addons/typed-query-document"]
}
}
]
},
}
In the relay standard exists an extra directive @connection for paging. It is at least used by the apollo and relay toolkits. ts-graphql-plugin complains that it doesn't know this directive. Can you whitelist it?