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(gatsby): Throw Typegen errors & add IGatsbyImageData to output #35683

Merged
merged 9 commits into from
May 19, 2022

Conversation

LekoArts
Copy link
Contributor

@LekoArts LekoArts commented May 17, 2022

Description

  • Make two GraphQL errors less verbose as they are thrown when there is also a typegen error. This way the terminal overview is better
  • Throw proper structured error for typegen errors
  • End activity and don't panic during develop
  • Always use validation for documents to get proper error messages
  • Update flag description and not mark as experimental anymore
  • Use IGatsbyImageData type for gatsbyImageData

Documentation

I'll add a docsUrl to the error in #35584

Related Issues

[ch50768]
[ch50542]
#35420 (comment)

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label May 17, 2022
@LekoArts LekoArts added topic: TypeScript Issues and PRs related to TS in general, public typings or gatsby-plugin-typescript and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels May 17, 2022
@LekoArts LekoArts changed the title fix(gatsby): Throw Typegen errors & other fixes fix(gatsby): Throw Typegen errors & add IGatsbyImageData to output May 17, 2022
@LekoArts LekoArts added this to the GraphQL Typegen milestone May 17, 2022
@aaronadamsCA
Copy link
Contributor

Oh good, I was just coincidentally checking how you worked around the generic JSON scalar type.

Related feature request: #33317

@aaronadamsCA
Copy link
Contributor

Also, if this helps, in our environment the gatsby-plugin-image#IGatsbyImageData syntax didn't work. We had to use a dynamic import expression (import('gatsby-plugin-image').IGatsbyImageData) instead.

@LekoArts
Copy link
Contributor Author

Also, if this helps, in our environment the gatsby-plugin-image#IGatsbyImageData syntax didn't work. We had to use a dynamic import expression (import('gatsby-plugin-image').IGatsbyImageData) instead.

Works in my testing. It adds

import type { IGatsbyImageData } from 'gatsby-plugin-image';

At the top of the file and then reuses that in the scalars

type Scalars = {
  GatsbyImageData: IGatsbyImageData;
  JSON: Record<string, unknown>;
};

@LekoArts
Copy link
Contributor Author

Oh, you were right. The global namespace doesn't work if you add an import, so I switched it to the dynamic import.

Luckily this was also caught by the e2e tests 👍

@LekoArts
Copy link
Contributor Author

@aaronadamsCA which other generic JSON scalars did you run into? I can change others, too

@aaronadamsCA
Copy link
Contributor

@LekoArts That was the only one we had encountered so far.

Looking forward to seeing this ship!

@wardpeet
Copy link
Contributor

Looks good, do you want to do the same for imageCDN located in gatsby-plugin-utils?

wardpeet
wardpeet previously approved these changes May 18, 2022
@LekoArts LekoArts merged commit e7fc88b into master May 19, 2022
@LekoArts LekoArts deleted the typegen-fixes-01 branch May 19, 2022 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: TypeScript Issues and PRs related to TS in general, public typings or gatsby-plugin-typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants