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(v5): type queryResult in Cells #8175

Merged
merged 10 commits into from
May 1, 2023
Merged

fix(v5): type queryResult in Cells #8175

merged 10 commits into from
May 1, 2023

Conversation

jtoar
Copy link
Contributor

@jtoar jtoar commented Apr 30, 2023

Fixes #7024 (comment). @Tobbe works in VS Code with yarn rwfw going, but do you think it's this simple?

image

@jtoar jtoar added the release:fix This PR is a fix label Apr 30, 2023
@jtoar jtoar added this to the next-release-patch milestone Apr 30, 2023
@jtoar jtoar requested a review from Tobbe April 30, 2023 01:19
@Tobbe
Copy link
Member

Tobbe commented Apr 30, 2023

do you think it's this simple?

Do we need to make the same change for Empty, Loading and Failure too?

@jtoar
Copy link
Contributor Author

jtoar commented Apr 30, 2023

@Tobbe ah yeah great catch, just pushed those changes up

@@ -104,14 +106,13 @@ export type CellSuccessData<TData = any> = Omit<Guaranteed<TData>, '__typename'>
export type CellSuccessProps<
TData = any,
TVariables extends OperationVariables = any
> = Partial<
Omit<
> = Partial<{
Copy link
Member

Choose a reason for hiding this comment

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

Sorry I didn't catch this earlier, but I wonder if Partial<> isn't in the wrong spot now. I could be wrong here, so please validate my claims. But I think what you're saying now is that queryResult might or might not be present. And updating might or might not be present.

Basically this:

type CellSuccessProps = {
  queryResult?: { ... }
  updating?: boolean
}

Whereas what we had before was everything "inside" queryResult being optional.

So, maybe what we need is something like

type CellSuccessProps = {
  queryResult: Partial<{ ... }>
  updating: boolean
}

I removed the ? after both queryResult and updating. I'm not sure if for example updating can be undefined, and if so, how React will treat <Success updating={undefined}>. If it can be undefined, and react then doesn't include it in the props for <Success>, then we need to add the ?.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I thought about this briefly. We had Partial wrapping the whole type before so pretty much everything except for the data comes back as being possible undefined:

image

Including updating:

image

It makes sense to make queryResult's contents Partial but not the prop itself, but making updating not possibly undefined would be a change I haven't considered yet. Open to anything though I just haven't through it through, was just trying to fix the bug

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With the typing the way it is I have to pass queryResult like this in the type test now; maybe it's not a big deal since it'll be passed by the Cell to Success, etc automatically: 6404619

Copy link
Member

Choose a reason for hiding this comment

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

Open to anything though I just haven't through it through, was just trying to fix the bug

You're right. Let's focus on the actual bug! 🙂

Copy link
Member

Choose a reason for hiding this comment

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

With the typing the way it is I have to pass queryResult like this in the type test now

I think that's correct. The "input" to a cell should/will have queryResult.

@jtoar jtoar merged commit 49ceefb into main May 1, 2023
@jtoar jtoar deleted the ds-v5/fix-queryResult-typing branch May 1, 2023 18:57
jtoar added a commit that referenced this pull request May 1, 2023
* fix(v5): type queryResult

* make type change for faliure and loading

* Partial queryResult's contents

* fix failing type test

* continue fixing type tests

* update test project fixture

* remove glob dependency

* fix type errors in smoke test

* revert changes to type tests
@jtoar jtoar modified the milestones: next-release-patch, v5.0.3 May 1, 2023
jtoar added a commit that referenced this pull request May 1, 2023
* fix(v5): type queryResult

* make type change for faliure and loading

* Partial queryResult's contents

* fix failing type test

* continue fixing type tests

* update test project fixture

* remove glob dependency

* fix type errors in smoke test

* revert changes to type tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:fix This PR is a fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants