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

ts-graphql-plugin does not understand directive @connection (relay) #118

Open
devkral opened this issue Aug 13, 2020 · 3 comments
Open

ts-graphql-plugin does not understand directive @connection (relay) #118

devkral opened this issue Aug 13, 2020 · 3 comments

Comments

@devkral
Copy link

devkral commented Aug 13, 2020

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?

@devkral
Copy link
Author

devkral commented Aug 13, 2020

this only happens with the validate command.

@Quramy
Copy link
Owner

Quramy commented Sep 24, 2020

You can tell custom directives with local schema.
see https://github.com/Quramy/ts-graphql-plugin#localschemaextensions

@kirkobyte
Copy link

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"]
        }
      }
    ]
  },
}

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

3 participants