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

fix Maybe only refers to a type, but is being used as a value here #4181

Merged

Conversation

leejh3224
Copy link
Contributor

Fix the issue related to the comment below.

comment
Thanks @borremosch @dotansimha!
Though if you have something like this (tested with 1.8.2-alpha-6ee6e064.78 ):

type MyType{
  myProperty: [SomeOtherType]
}

Will result in:

@TypeGraphQL.Field(type => \[**Maybe**\<SomeOtherType>], { nullable: true })
myProperty!: Maybe<Array<Maybe\<SomeOtherType>>>;

So ts will say: 'Maybe' only refers to a type, but is being used as a value here.

Originally posted by @groege in #2177 (comment)

@leejh3224
Copy link
Contributor Author

@dotansimha
It seems like the last CI check (The Guild) has failed but I can't check the log or anything.
Could you please check why it failed?

@dotansimha dotansimha force-pushed the master branch 3 times, most recently from 2aa2243 to 4a5af11 Compare June 8, 2020 12:41
@dotansimha
Copy link
Owner

Thank you @leejh3224 !
You can ignore this CI check for now, it's our internal CI process, we'll fix that later this week :)

Regarding this PR, I think maybe you can use this.clearOptional ? it should remove the maybe wrapper for you.

@leejh3224
Copy link
Contributor Author

Great! I’ll check that out!

@leejh3224
Copy link
Contributor Author

this.clearOptional works for me. Great!

@dotansimha
Copy link
Owner

Perfect, we can get this merged. Thank you @leejh3224 !

@dotansimha dotansimha merged commit 1ceb41c into dotansimha:master Jun 10, 2020
@leejh3224 leejh3224 deleted the fix-maybe-only-refers-to-a-type-error branch June 10, 2020 12:38
@theguild-bot
Copy link
Collaborator

The latest changes of this PR are available as alpha in npm: 1.15.3-alpha-1ceb41cc.0

Quickly update your package.json by running:

npx match-version @graphql-codegen 1.15.3-alpha-1ceb41cc.0

@OLDIN
Copy link

OLDIN commented Aug 29, 2020

A use ver. 1.17.8 but still getting this problem
Some types generated fine and some did not.
Namely the types in the array

@TypeGraphQL.InputType()
export class CalendarEvent_Bool_Exp {

  @TypeGraphQL.Field(type => [Maybe<CalendarEvent_Bool_Exp>], { nullable: true })
  _and!: Maybe<Array<Maybe<CalendarEvent_Bool_Exp>>>;

  @TypeGraphQL.Field(type => CalendarEvent_Bool_Exp, { nullable: true })
  _not!: Maybe<CalendarEvent_Bool_Exp>;

  @TypeGraphQL.Field(type => [Maybe<CalendarEvent_Bool_Exp>], { nullable: true })
  _or!: Maybe<Array<Maybe<CalendarEvent_Bool_Exp>>>;

  @TypeGraphQL.Field(type => Cart_Bool_Exp, { nullable: true })
  cartItems!: Maybe<Cart_Bool_Exp>;
...

@ardatan
Copy link
Collaborator

ardatan commented Aug 29, 2020

@OLDIN Could you please create a new issue with a minimal reproduction using our CodeSandbox template?

@OLDIN
Copy link

OLDIN commented Aug 29, 2020

@ardatan ok. issue

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

Successfully merging this pull request may close these issues.

None yet

5 participants