graphql-codegen-factories
graphql-codegen-factories copied to clipboard
using `graphql-codegen-factories/operations` fails on `this.schema.getRootType`
With plugins as:
plugins: [
'typescript',
'typescript-operations',
'typescript-urql',
'graphql-codegen-factories/schema',
'graphql-codegen-factories/operations',
],
I get this error message [FAILED] this.schema.getRootType is not a function
Could you share a reproduction please? Feel free to use the minimal example as a starting point: https://stackblitz.com/github/zhouzi/graphql-codegen-factories/tree/main/examples/minimal?file=package.json
It could come from a specificity in the schema, a graphql version, mixing some plugins together or anything. With a reproduction, it'll be much easier to track down what's going wrong 🙏
@jsve are you still having issues using the plugin? It'd be really helpful if you could share a reproduction.
I am closing this issue but feel free to reopen with more details.
Same issue with the latest graphql codegen:
"@graphql-codegen/cli": "5.0.0",
"@graphql-codegen/client-preset": "4.1.0",
And still same:
"@graphql-codegen/cli": "5.0.2",
"@graphql-codegen/client-preset": "4.2.4",
Changing to these three instead of preset doesn't work either:
"@graphql-codegen/typescript": "4.0.6",
"@graphql-codegen/typescript-operations": "4.2.0",
"@graphql-codegen/typescript-react-apollo": "4.3.0",
Looks to me like the format of the schema in the file graphql-codegen-factories/build/operations/FactoriesOperationsVisitor.js
is not GraphQLSchema
or an extension of it.
I'll update the versions and see if I can reproduce this bug.
Running console.log(Object.getOwnPropertyNames(this.schema.__proto__));
gives:
[
'constructor',
'getQueryType',
'getMutationType',
'getSubscriptionType',
'getTypeMap',
'getType',
'getPossibleTypes',
'getImplementations',
'isPossibleType',
'isSubType',
'getDirectives',
'getDirective',
'toConfig'
]
Thanks for sharing! I suspect the issue is that the plugin doesn't use the same version of the packages as the project. But I will have to run some tests.
@Cordazar could you share the parts of your package.json that are related to graphql/codegen, please?
"@graphql-codegen/add": "5.0.2",
"@graphql-codegen/cli": "5.0.2",
"@graphql-codegen/client-preset": "4.2.4",
"@graphql-codegen/typescript": "4.0.6",
"@graphql-codegen/typescript-operations": "4.2.0",
"@graphql-codegen/typescript-react-apollo": "4.3.0",
"graphql-codegen-typescript-mock-data": "3.7.1",
I've tried it both with the preset: 'client'
option and also manually by using the plugins directly:
'typescript',
'typescript-operations',
'typescript-react-apollo',
'graphql-codegen-factories/schema',
'graphql-codegen-factories/operations'