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

using graphql-codegen-factories/operations fails on this.schema.getRootType #73

Open
jsve opened this issue Feb 6, 2023 · 10 comments
Open

Comments

@jsve
Copy link

jsve commented Feb 6, 2023

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

@zhouzi
Copy link
Owner

zhouzi commented Feb 12, 2023

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 🙏

@zhouzi
Copy link
Owner

zhouzi commented Feb 27, 2023

@jsve are you still having issues using the plugin? It'd be really helpful if you could share a reproduction.

@zhouzi
Copy link
Owner

zhouzi commented Mar 25, 2023

I am closing this issue but feel free to reopen with more details.

@zhouzi zhouzi closed this as completed Mar 25, 2023
@alexsandiiarov
Copy link

Same issue with the latest graphql codegen:

"@graphql-codegen/cli": "5.0.0",
"@graphql-codegen/client-preset": "4.1.0",

@Cordazar
Copy link

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.

@zhouzi
Copy link
Owner

zhouzi commented Feb 26, 2024

I'll update the versions and see if I can reproduce this bug.

@zhouzi zhouzi reopened this Feb 26, 2024
@Cordazar
Copy link

Running console.log(Object.getOwnPropertyNames(this.schema.__proto__)); gives:

[
  'constructor',
  'getQueryType',
  'getMutationType',
  'getSubscriptionType',
  'getTypeMap',
  'getType',
  'getPossibleTypes',
  'getImplementations',
  'isPossibleType',
  'isSubType',
  'getDirectives',
  'getDirective',
  'toConfig'
]

@zhouzi
Copy link
Owner

zhouzi commented Feb 26, 2024

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.

@zhouzi
Copy link
Owner

zhouzi commented Mar 3, 2024

@Cordazar could you share the parts of your package.json that are related to graphql/codegen, please?

@Cordazar
Copy link

Cordazar commented Mar 4, 2024

    "@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'

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

4 participants