-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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: fix fetchError persisting across different fetchers #2653
Conversation
🦋 Changeset detectedLatest commit: cafe2b2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much @dylanowen for catching this! That's indeed a bug that got in with one of the refactorings we did in the past months (most likely my bad 😓 ). The fix itself is perfect, just have some tiny nits!
Can you also add a changeset here that describes the fix? (I just noticed that this is still missing in our CONTRIBUTING.md
🙈 ). Just run yarn changeset
in the repository root and the CLI will walk you through how to create a changeset which is just a markdown file that you need to commit and push to the branch.
@dylanowen and you need to sign the CLA in order to become a contributor. Just click on the details link next to the failing GitHub check, that should walk you through everything. |
Codecov Report
@@ Coverage Diff @@
## main #2653 +/- ##
==========================================
+ Coverage 65.70% 69.46% +3.75%
==========================================
Files 85 71 -14
Lines 5106 4208 -898
Branches 1631 1414 -217
==========================================
- Hits 3355 2923 -432
+ Misses 1747 1280 -467
- Partials 4 5 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Co-authored-by: Thomas Heyenbrock <[email protected]>
@thomasheyenbrock thanks for the quick review! I'm still working on the CLA but should have that ready soon. |
thanks for this! @dylanowen make sure to sign the CLA bot with the email you used to sign the commits, it's very specific about this but won't tell you this is why 😆 |
@acao Sorry for the CLA delay but it should be all set now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to merge!
looks related to #2771 |
@dylanowen I'm working on a small PR (#2778 ) to update some styling that's unrelated to this PR, but getting a failing test that is part of this PR.
👆 this is failing because those selectors don't exist. In fact, I can't find a record of them existing at the time this PR was created. @acao @thomasheyenbrock Shouldn't this failing test have been caught by now? Looks like this PR didn't go through the standard set of checks. |
@jonathanawesome I'm pretty sure this is caused by the long lag time between my PR being tested and me getting my CLA signed. When I opened this PR those selectors existed:
|
ahh...there it is. Thanks for the explanation, makes sense now. I've got the fix in with #2778. |
Thanks for the quick fix! I was wondering if it'd be better to not depend on the let foundError = null;
function ErrorIcon() {
foundError = useSchemaContext({nonNull: true}).fetchError;
return <div/>;
}
const ERROR_PLUGIN = {
title: 'test',
icon: ErrorIcon,
content: () => <div />,
};
function firstFetcher() {
return Promise.reject('Schema Error');
}
function secondFetcher() {
return Promise.resolve(simpleIntrospection);
}
// Use a bad fetcher for our initial render
const { rerender } = render(<GraphiQL fetcher={firstFetcher} plugins={[ERROR_PLUGIN]} />);
await wait();
expect(foundError).toBeTruthy()
// Re-render with valid fetcher
rerender(<GraphiQL fetcher={secondFetcher} plugins={[ERROR_PLUGIN]} />);
await wait();
expect(foundError).not.toBeTruthy(); But I'll defer to whatever solution you think is best. |
I think you've a good point...the Doc Explorer isn't in the DOM by default anymore (it must have been when you added your test), so I added a fireEvent to the test to ensure that it's there. I also added an additional test closer to the component. These are good, the-way-the-user-sees-it tests, so I think they're sufficient. |
Ahhh nice, even better 👍 |
If you construct a
GraphiQL
instance with a bad fetcherfetchError
gets persisted inSchemaContextType
forever. You can still fetch a new schema but theDocExplorer
will always show "Error fetching schema"