documentation icon indicating copy to clipboard operation
documentation copied to clipboard

TypeError: Cannot read property 'name' of undefined (graphql codegen with flow)

Open josefjadrny opened this issue 4 years ago • 1 comments

Hi, i am experiencing the following error with graphql codegenerator tool with flow. Generated code looks fine, but documentation returns an Error.

test.flow.js

// @flow

/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {|
  ID: string,
  String: string,
  Boolean: boolean,
  Int: number,
  Float: number,
|};

/** Some description */
export type EpisodeAggregation = {|
  ...Aggregation,
  ...{|
    __typename?: 'EpisodeAggregation',
    /** The ID of an object */
  id: $ElementType<Scalars, 'ID'>,
  |}
|};

export type Aggregation = {|
  __typename?: 'Aggregation',
  /** The ID of an object */
  id: $ElementType<Scalars, 'ID'>,
|};

$ documentation lint test.flow.js

TypeError: Cannot read property 'name' of undefined
    at isObjectSpreadAndExactUtilTypeProperty (/usr/local/lib/node_modules/documentation/src/infer/properties.js:15:26)
    at /usr/local/lib/node_modules/documentation/src/infer/properties.js:87:13
    at Array.forEach (<anonymous>)
    at inferProperties (/usr/local/lib/node_modules/documentation/src/infer/properties.js:79:18)
    at Array.inferProperties (/usr/local/lib/node_modules/documentation/src/infer/properties.js:104:7)
    at /usr/local/lib/node_modules/documentation/src/index.js:40:25
    at Array.map (<anonymous>)
    at /usr/local/lib/node_modules/documentation/src/index.js:149:48
    at arrayMap (/usr/local/lib/node_modules/documentation/node_modules/lodash/lodash.js:639:23)
    at map (/usr/local/lib/node_modules/documentation/node_modules/lodash/lodash.js:9580:14)

My code is autogenerated by https://graphql-code-generator.com from this query

"Some description"
type EpisodeAggregation implements Aggregation {
    "The ID of an object"
    id: ID!
}

type Aggregation {
    "The ID of an object"
    id: ID!
}
  • What version of documentation.js are you using?: [email protected]
  • How are you running documentation.js (on the CLI, Node.js API, Grunt, other?): CLI

josefjadrny avatar Jan 18 '21 16:01 josefjadrny

Remove this comment /** Some descriptition */ and it magically works. In my case, unfortunately, it is autogenerated.

josefjadrny avatar Jan 18 '21 16:01 josefjadrny