graphql-schema icon indicating copy to clipboard operation
graphql-schema copied to clipboard

Actor type is generated incorrectly

Open tomasreimers opened this issue 2 years ago • 3 comments

Hi,

The actor type seems to be generated incorrectly, based on the exported type:

/** Represents an object which can take actions on GitHub. Typically a User or Bot. */
export type Actor = {
  /** A URL pointing to the actor's public avatar. */
  avatarUrl: Scalars['URI'];
  /** The username of the actor. */
  login: Scalars['String'];
  /** The HTTP path for this actor. */
  resourcePath: Scalars['URI'];
  /** The HTTP URL for this actor. */
  url: Scalars['URI'];
};

https://github.com/octokit/graphql-schema/blob/master/schema.d.ts#L71-L80

However, I can also query user or bot properties off of this (as mentioned by the comment); seems as if the correct definition would be:

export type Actor = (User | Bot) & {
  ...
};

Happy to make a pull request; however this seems auto-generated by another package (https://github.com/dotansimha/graphql-code-generator#readme), so wanted to first ask if anyone here had any insight before escalating the problem there?

tomasreimers avatar Aug 11 '21 21:08 tomasreimers

Hi @tomasreimers! Yeah the types are autogenerated and contributed by the community. I'm not using them myself yet. It sounds like something that would need to be resolved in https://github.com/dotansimha/graphql-code-generator#readme?

gr2m avatar Aug 11 '21 21:08 gr2m

Okay, bug filed here: https://github.com/dotansimha/graphql-code-generator/issues/6539

I couldn't find a previous discussion, but I have to imagine this has been discussed before. Let's see what they say!

tomasreimers avatar Aug 23 '21 02:08 tomasreimers

The fix suggested in https://github.com/dotansimha/graphql-code-generator/issues/6539 does work and is part of my fork which is also published to npm, with automatic updates enabled:

zhouzi avatar May 19 '22 17:05 zhouzi

:tada: This issue has been resolved in version 13.9.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Apr 04 '23 00:04 github-actions[bot]