Describe the bug
AggregateError when query param name same with the directive
To Reproduce
Steps to reproduce the behavior:
write client schema like and generate
query registrations($filter: RegistrationFilterInput, $page: PageInfo) {
registrations(filter: $filter, page: $page) @connection(key: "registrations", filter: ["filter"]) {
items {
# ...
}
pageIndex
}
}
type RegistrationPage implements Pageable {
items: [Registration!]
pageSize: Int!
pageIndex: Int!
total: Int!
}
type Query {
registrations(filter: RegistrationFilterInput, pageInfo: PageInfo): RegistrationPage
}
registrations(filter: $filter, pageInfo: $pageInfo) @connection(key: "registrations", filter: ["filter"]){
items {
...RegistrationFields
}
pageIndex
pageSize
total
}
codegen.yml config file:overwrite: true
schema: "server.graphql"
documents: ["src/**/*.ts", "src/**/*.graphql"]
generates:
src/graphql.ts:
plugins:
- "typescript"
- "typescript-operations"
- "typescript-document-nodes"
config:
avoidOptionals: false
exportFragmentSpreadSubTypes: true
enumsAsTypes: false
Expected behavior
export the documents with the directive
Environment:
@graphql-codegen/...: Additional context
> graphql-codegen --config codegen.yml --clientSchema clientDirective.graphql
โ Parse configuration
โฏ Generate outputs
โฏ Generate src/graphql.ts
โ Load GraphQL schemas
โ Load GraphQL documents
โ Generate
โ at /Users/xiaoliu/workspace/frontend-main/src/components/registration/RegistrationHooks/registration.query.graphql:7:137
Found 1 error
โ src/graphql.ts
AggregateError:
GraphQLDocumentError: Expected type RegistrationFilterInput, found ["filter"].
at /Users/xiaoliu/workspace/frontend-main/src/components/registration/RegistrationHooks/registration.query.graphql:7:137
at Object.checkValidationErrors (/Users/xiaoliu/workspace/frontend-main/node_modules/@graphql-toolkit/common/index.cjs.js:431:15)
at Object.codegen (/Users/xiaoliu/workspace/frontend-main/node_modules/@graphql-codegen/core/index.cjs.js:89:16)
at async process (/Users/xiaoliu/workspace/frontend-main/node_modules/@graphql-codegen/cli/bin.js:764:56)
at async Promise.all (index 0)
at async /Users/xiaoliu/workspace/frontend-main/node_modules/@graphql-codegen/cli/bin.js:771:37
at async Task.task (/Users/xiaoliu/workspace/frontend-main/node_modules/@graphql-codegen/cli/bin.js:567:17)
AggregateError:
GraphQLDocumentError: Expected type RegistrationFilterInput, found ["filter"].
at /Users/xiaoliu/workspace/frontend-main/src/components/registration/RegistrationHooks/registration.query.graphql:7:137
at Object.checkValidationErrors (/Users/xiaoliu/workspace/frontend-main/node_modules/@graphql-toolkit/common/index.cjs.js:431:15)
at Object.codegen (/Users/xiaoliu/workspace/frontend-main/node_modules/@graphql-codegen/core/index.cjs.js:89:16)
at async process (/Users/xiaoliu/workspace/frontend-main/node_modules/@graphql-codegen/cli/bin.js:764:56)
at async Promise.all (index 0)
at async /Users/xiaoliu/workspace/frontend-main/node_modules/@graphql-codegen/cli/bin.js:771:37
at async Task.task (/Users/xiaoliu/workspace/frontend-main/node_modules/@graphql-codegen/cli/bin.js:567:17)
Hi @xiaoliu-heng ,
Can you please share a live reproduction? We need to have a real, working environment with this issue, please make sure to use latest versions, since it seems like some deps are outdated in the callstack you shared.
I'm not sure it's something related to codegen, because the error seems like a graphql error, coming from graphql-js itself.
Hi, I'm experiencing a similar issue, @xiaoliu-heng do you have any updates on reproducing it?
To solve this problem just add the following line to your schema.graphql file:
directive @connection(key: String!, filter: [String!]) on FIELD
@dotansimha I didn't find where graphql-codegen adds the wrong @connection directive definition for making a PR.
BTW It will be nice if this directive will be added to the react-apollo plugin.
@dotansimha @osalama7 sorry I'm late. Codesandbox
to reproduce, just remove the directive.graphql
@nodkz It works. thanks!
To solve this problem just add the following line to your
schema.graphqlfile:directive @connection(key: String!, filter: [String!]) on FIELD@dotansimha I didn't find where graphql-codegen adds the wrong
@connectiondirective definition for making a PR.BTW It will be nice if this directive will be added to the
react-apolloplugin.
Actually, we are not adding that at all. Codegen doesn't do any schema/operations manipulations, so I can only assume this directive comes from somewhere within @xiaoliu-heng 's code.
As I said, this error is coming directly from graphql-js, and I'm not sure there is something we can do about it.
Most helpful comment
To solve this problem just add the following line to your
schema.graphqlfile:@dotansimha I didn't find where graphql-codegen adds the wrong
@connectiondirective definition for making a PR.BTW It will be nice if this directive will be added to the
react-apolloplugin.