Skip to content

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.

4 participants