Skip to content

fix flow type for nestedPath #298

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

Merged
merged 3 commits into from
Jun 30, 2021
Merged

fix flow type for nestedPath #298

merged 3 commits into from
Jun 30, 2021

Conversation

gyDBD
Copy link
Contributor

@gyDBD gyDBD commented Jun 30, 2021

Issue:

codegen generate wrong flow type when I use nestedPath.

dataloader-config.yaml

   getFilmsV2:
        docsLink: https://swapi.dev/documentation#films
        isBatchResource: true
        batchKey: film_ids
        newKey: film_id
        nestedPath: properties

Status Quo

Screen Shot 2021-06-30 at 9 41 54 AM

The flow type of response is any, which is wrong!

after my change in src/genTypeFlow.ts

Screen Shot 2021-06-30 at 9 43 22 AM

We get the correct flow type.

What's wrong?

If the response is nested in some path, we need to first unwrap it. Then if it's a batch resource, we do $ElementType<${retVal}, 0> The order of two if-else statement matters!

Test Done

make test passed
Also see my swapi example ^ (screen shot above)

@gyDBD gyDBD requested review from kkellyy and magicmark June 30, 2021 16:57
@gyDBD gyDBD requested a review from kkellyy June 30, 2021 17:43
Copy link
Collaborator

@magicmark magicmark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@gyDBD gyDBD merged commit d00d9e0 into master Jun 30, 2021
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.

3 participants