Graphql-code-generator: TypeError: camelCase.camelCase is not a function

Created on 2 Jan 2020  Â·  15Comments  Â·  Source: dotansimha/graphql-code-generator

Describe the bug
type error

To Reproduce
Steps to reproduce the behavior:

gql-gen --config codegen.yml

then this:
TypeError: camelCase.camelCase 
is not a function
        at ReactApolloVisitor._buil
dHooksJSDoc (/home/capaj/work-repos
/looop/project-alpha3/node_modules/
@graphql-codegen/typescript-react-a
pollo/index.cjs.js:148:23)
        at ReactApolloVisitor._buil
dHooks (/home/capaj/work-repos/looo
p/project-alpha3/node_modules/@grap
hql-codegen/typescript-react-apollo
/index.cjs.js:176:34)
        at ReactApolloVisitor.build
Operation (/home/capaj/work-repos/l
ooop/project-alpha3/node_modules/@g
raphql-codegen/typescript-react-apo
llo/index.cjs.js:233:52)
        at ReactApolloVisitor.Opera
tionDefinition (/home/capaj/work-re
pos/looop/project-alpha3/node_modul
es/@graphql-codegen/visitor-plugin-
common/index.cjs.js:1768:33)
        at Object.visit 
(/home/capaj/work-repos/looop/proje
ct-alpha3/node_modules/graphql/lang
uage/visitor.js:242:26)
        at Object.plugin 
(/home/capaj/work-repos/looop/proje
ct-alpha3/node_modules/@graphql-cod
egen/typescript-react-apollo/index.
cjs.js:249:35)
        at executePlugin 
(/home/capaj/work-repos/looop/proje
ct-alpha3/node_modules/@graphql-cod
egen/core/index.cjs.js:60:41)
        at process._tickCallback (i
nternal/process/next_tick.js:68:7)
    TypeError: camelCase.camelCase 
is not a function
        at ReactApolloVisitor._buil
dHooksJSDoc (/home/capaj/work-repos
/looop/project-alpha3/node_modules/
@graphql-codegen/typescript-react-a
pollo/index.cjs.js:148:23)
        at ReactApolloVisitor._buil
dHooks (/home/capaj/work-repos/looo
p/project-alpha3/node_modules/@grap
hql-codegen/typescript-react-apollo
/index.cjs.js:176:34)
        at ReactApolloVisitor.build
Operation (/home/capaj/work-repos/l
ooop/project-alpha3/node_modules/@g
raphql-codegen/typescript-react-apo
llo/index.cjs.js:233:52)
        at ReactApolloVisitor.Opera
tionDefinition (/home/capaj/work-re
pos/looop/project-alpha3/node_modul
es/@graphql-codegen/visitor-plugin-
common/index.cjs.js:1768:33)
        at Object.visit 
(/home/capaj/work-repos/looop/proje
ct-alpha3/node_modules/graphql/lang
uage/visitor.js:242:26)
        at Object.plugin 
(/home/capaj/work-repos/looop/proje
ct-alpha3/node_modules/@graphql-cod
egen/typescript-react-apollo/index.
cjs.js:249:35)
        at executePlugin 
(/home/capaj/work-repos/looop/proje
ct-alpha3/node_modules/@graphql-cod
egen/core/index.cjs.js:60:41)
        at process._tickCallback (i
nternal/process/next_tick.js:68:7)
  1. My GraphQL schema:
I don't think it's needed, I can amend this if it is
  1. My GraphQL operations:
I don't think it's needed, I can amend this if it is
  1. My codegen.yml config file:
overwrite: true

generates:
  front-end/src/graphql/gqlPrivateSchema.tsx:
    schema: 'gqlSchemas/private.graphql'
    documents:
      - 'front-end/**/*.gql'
      - '!front-end/src/app-admin/**'
    plugins:
      - typescript
      - typescript-operations
      - typescript-react-apollo
      - add: '/* THIS IS A GENERATED FILE, DO NOT EDIT */'
  front-end/src/app-admin/graphql/gqlSuperuserSchema.tsx:
    schema: 'gqlSchemas/superuser.graphql'
    documents:
      - 'front-end/src/app-admin/**'
    plugins:
      - typescript
      - typescript-operations
      - typescript-react-apollo
      - add: '/* THIS IS A GENERATED FILE, DO NOT EDIT */'
  front-end/src/graphql/gqlPrivateSchemaFragments.tsx:
    schema: 'gqlSchemas/private.graphql'
    plugins:
      - fragment-matcher
      - add: '/* THIS IS A GENERATED FILE, DO NOT EDIT */'
config:
  withHooks: true
  withHOC: false
  withComponent: false
  apolloReactHooksImportFrom: '@apollo/react-hooks'
  reactApolloVersion: 3
  scalars:
    EmailAddressWithTLD: string
    NonNegativeFloat: number
    NonNegativeInt: number
    PositiveInt: number
    DateTime: string
  namingConvention:
    enumValues: keep
hooks:
  afterOneFileWrite:
    - prettier --write

Expected behavior
no type error

Environment:

  • OS:
  • @graphql-codegen/...: 1.10.1
  • NodeJS: 10.17.0

Additional context

On 1.9.1 it compiles without any issue

bug core waiting-for-release

Most helpful comment

Also experiencing this after the latest version update

All 15 comments

Also experiencing this after the latest version update

This was introduced in #3145

Could you try with the following version? If you still have any error, please share the stack trace.
1.10.1-alpha-c25db63c.4

Doesn't seem to fix the problem for me with versions:
@graphql-codegen/[email protected]
@graphql-codegen/[email protected]

  ✖ src/generated/graphql.tsx
    TypeError: camelCase.camelCase is not a function
        at ReactApolloVisitor._buildOperationHoc (/node_modules/@graphql-codegen/typescript-react-apollo/index.cjs.js:93:27)
        at ReactApolloVisitor.buildOperation (/node_modules/@graphql-codegen/typescript-react-apollo/index.cjs.js:232:48)
        at ReactApolloVisitor.OperationDefinition (/node_modules/@graphql-codegen/visitor-plugin-common/index.cjs.js:1768:33)
        at Object.visit (/node_modules/graphql/language/visitor.js:242:26)
        at Object.plugin (/node_modules/@graphql-codegen/typescript-react-apollo/index.cjs.js:249:35)
        at executePlugin (/node_modules/@graphql-codegen/core/index.cjs.js:50:41)
        at processTicksAndRejections (internal/process/task_queues.js:93:5)
        at async /node_modules/@graphql-codegen/core/index.cjs.js:106:24
        at async Promise.all (index 2)
        at async Object.codegen (/node_modules/@graphql-codegen/core/index.cjs.js:135:20)
        at async process (/node_modules/@graphql-codegen/cli/bin.js:781:56)
        at async Promise.all (index 0)
        at async /node_modules/@graphql-codegen/cli/bin.js:788:37
        at async Task.task (/node_modules/@graphql-codegen/cli/bin.js:580:17)
    TypeError: camelCase.camelCase is not a function
        at ReactApolloVisitor._buildOperationHoc (/node_modules/@graphql-codegen/typescript-react-apollo/index.cjs.js:93:27)
        at ReactApolloVisitor.buildOperation (/node_modules/@graphql-codegen/typescript-react-apollo/index.cjs.js:232:48)
        at ReactApolloVisitor.OperationDefinition (/node_modules/@graphql-codegen/visitor-plugin-common/index.cjs.js:1768:33)
        at Object.visit (/node_modules/graphql/language/visitor.js:242:26)
        at Object.plugin (/node_modules/@graphql-codegen/typescript-react-apollo/index.cjs.js:249:35)
        at executePlugin (/node_modules/@graphql-codegen/core/index.cjs.js:50:41)
        at processTicksAndRejections (internal/process/task_queues.js:93:5)
        at async /node_modules/@graphql-codegen/core/index.cjs.js:106:24
        at async Promise.all (index 2)
        at async Object.codegen (/node_modules/@graphql-codegen/core/index.cjs.js:135:20)
        at async process (/node_modules/@graphql-codegen/cli/bin.js:781:56)
        at async Promise.all (index 0)
        at async /node_modules/@graphql-codegen/cli/bin.js:788:37
        at async Task.task (/node_modules/@graphql-codegen/cli/bin.js:580:17)

I was able to get my setup working with this combination:
@graphql-codegen/[email protected]
@graphql-codegen/[email protected]

@coreylight Could you try 1.10.1-alpha-c25db63c.4 canary version for all packages (both ts-react-apollo and cli)?

Same problem. 1.10.1-alpha-c25db63c.4 does not solve it for me

I installed 1.8.3. Works fine for me.

https://codesandbox.io/s/friendly-glade-x1u9w
Could you help me reproduce it? You can see there is no errors in this sandbox.

I've tried reproduce it here.
https://codesandbox.io/s/gifted-golick-xjg0h?fontsize=14&hidenavigation=1&theme=dark

In sandbox I have → Cannot find module 'change-case': )
Hope it will help you

@kolengri Your case is a little bit different :) change-case has introduced some breaking changes recently. That package is independent from codegen. But we decided to add some workaround code while loading the function by usingnamingConventionoption.
1.10.1-alpha-3fc7bb8a.6 should work for all of you :)

Getting the camelCase error with 1.10.0 and 1.10.1-alpha-3fc7bb8a.6. 1.9.1 works.

overwrite: true
generates:
  src/__generated__/graphql.tsx:
    schema:
      - '../**/*.graphql'
    documents: './src/GraphQL/**/*.gql'
    plugins:
      - add: // tslint:disable
      - typescript
      - typescript-operations
      - typescript-react-apollo
      - typescript-compatibility
  # Introspection schema for mock server
  src/__generated__/schema.json:
    schema:
      - '../**/*.graphql'
    documents: './src/GraphQL/**/*.gql'
    plugins:
      - introspection

@PhishyFish Could you share a reproduction using our codesandbox template? Thanks!
https://codesandbox.io/s/github/dotansimha/graphql-code-generator-issue-sandbox-template

I installed 1.10.1-alpha-d8c376b0.18 and it fixed the problem. @ardatan Thanks.

Fixed in 1.11.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fvisticot picture fvisticot  Â·  3Comments

dotansimha picture dotansimha  Â·  3Comments

zenVentzi picture zenVentzi  Â·  3Comments

quolpr picture quolpr  Â·  3Comments

rogerg93 picture rogerg93  Â·  3Comments