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

Query type generation fails sometimes #162

Closed
KaiseiSato opened this issue May 7, 2021 · 6 comments
Closed

Query type generation fails sometimes #162

KaiseiSato opened this issue May 7, 2021 · 6 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@KaiseiSato
Copy link

Overview

When running gatsby build, type generation sometimes fails.
The output file is generated. (e.g., gatsby-types.d.ts)
I am using the Headless CMS service.
The data type definitions are always generated successfully, but the query type generation fails sometimes.
Most query types are generated correctly.
But some types are sometimes completed without being generated.
When it fails, I have confirmed that the processing order of the program is abnormal.

Source for verification

gatsby-node.ts

...
(line 61)
try {
    const code = await readFile(componentPath);
    console.log('debug 1');
    const extractedSDL = await gqlPluckFromCodeString(
        componentPath,
        code,
        GRAPHQL_TAG_PLUCK_OPTIONS,
    );
    console.log('debug 2');
    if (extractedSDL) {
        console.log('debug 3');
        const document = parseGraphQLSDL(componentPath, extractedSDL, { noLocation: true });
        console.log('debug 4');
        trackedSource.set(componentPath, document);
        console.log('debug 5');
    }
} catch (error) {
    reporter.error(`[typegen] Fail to extract GraphQL documents from ${componentPath}`, error);
}

...

(line 95)
unsubscribeQueryExtraction();
console.log('END');

...

Result when completed correctly

...
debug 1
debug 2
debug 3
debug 4
debug 5
debug 1
debug 2
debug 3
debug 4
debug 5
END

...

Result when not completed correctly

debug 1
debug 2
debug 3
debug 4
debug 5
END
debug 1
debug 2
debug 3
debug 4
debug 5

@KaiseiSato KaiseiSato changed the title Type generation sometimes completes incomplete. Query type generation fails sometimes May 7, 2021
@cometkim cometkim added the bug Something isn't working label May 7, 2021
@cometkim cometkim self-assigned this May 7, 2021
@cometkim cometkim added this to the v3 milestone May 7, 2021
@cometkim
Copy link
Owner

cometkim commented May 7, 2021

Thanks @KaiseiSato,

just to confirm if this is same issue with #160 did you enable PARRAEL_SOURCING flag?

@KaiseiSato
Copy link
Author

KaiseiSato commented May 7, 2021

@cometkim
I have not changed the PARALLEL_SOURCING flag.
So it's not enabled.

@j-yamamoto
Copy link

@cometkim
Thank you for recognizing this as an issue. I don't mean to push you, but is it gonna be fixed anytime soon?
If not, could you share us workarounds to avoid this issue?

@cometkim cometkim mentioned this issue May 10, 2021
Closed
30 tasks
@cometkim
Copy link
Owner

@j-yamamoto I'm not gonna fix this issue in v2 but in v3. Watch #138 for the progress.

v3 fix this issue by introducing a scheduler that relies on actual schema/definitions change instead of the order of lifecycle API.

I recommend that to commit and review the generated type definitions together for better DX.

@cometkim
Copy link
Owner

cometkim commented Mar 14, 2022

I recommend that to commit and review the generated type definitions together for better DX.

I admit it wasn't a good guide. Schema output was not stable in v2.

I fixed this (and also the schema output is now stable!) in v3 and it is available in the current RC version.

cometkim added a commit that referenced this issue Jun 12, 2022
rc.0
- implemente XState based scheduler
- stabilize schema output
- bump GCG
- upgrade yarn to v3
- rewritten core logics
- upgrade eslint to v8
- upgrade plugin's dependencies
- pin graphql version
- rewrite emitSchema service
- rewriten emitPluginDocument service
- rewriten codegen service
- add TS & Flow examples

rc.1
- skip running on cloud build
- fix config validation
- more contexture reporting
- turn `flattenGeneratedTypesIncludeFragments` true
- stabilize documents
- change maybe type to use `null` instead of `undefined`
- update README

rc.2
- add mdx example
- MDX example to validate regression of [#117]
- update dependencies
- added support for `GatsbyImageData` scalar

Resolves #40
Resolves #103
Resolves #104
Resolves #109
Fixes #113
Fixes #117
Fixes #120
Resolves #122
Fixes #124
Resolves #131
Fixes #139, #99
Resolves #146
Fixes #157
Fixes #159
Fixes #160
Fixes #161
Fixes #162
Resolves #168
Resolves #169
Fixes #171

[#117]: #117
@cometkim
Copy link
Owner

Please feel free to report another issue If this is reproduced after v3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants