-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Create method that verificates if an instance was created, in order t… #10409
Conversation
…o make it reusable. In this case, it was necessary to use it before the assignment of the cancellableToken variable
Codecov Report
@@ Coverage Diff @@
## main #10409 +/- ##
=======================================
Coverage 83.78% 83.79%
=======================================
Files 182 182
Lines 16396 16399 +3
Branches 3441 3441
=======================================
+ Hits 13738 13742 +4
+ Misses 2580 2579 -1
Partials 78 78
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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 for the contribution! Overall LGTM, have a couple comments.
|
||
expect(spyon).toBeCalledWith(url, init); | ||
}); | ||
|
||
test('call isInstanceCreated', () => { |
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.
Could you create a test to assert that createInstance
is no called when an instance already exists?
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.
Done!
@@ -359,6 +357,12 @@ export class GraphQLAPIClass { | |||
return response; | |||
} | |||
|
|||
async isInstanceCreated() { |
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.
This reads more like it should return a boolean. Maybe something like createInstanceIfNotCreated
would be a better fit here.
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.
Done! I agree with the name, thanks for the suggestion 🙂
It looks like you accidentally included some format changes to the CHANGELOGs. Could remove these changes? Then it should be good to merge. |
0aa0ca2
to
0d6c3f5
Compare
@dpilch fixed |
Thank you for this contribution! We've merged your change to main and expect it to go out in the release tomorrow. |
Hello. I've opened this pull request due to an issue we faced on our project while using amplify, where the graphql class could not read the getCancellableToken variable
We found out that this was happening because an instance was not being created before calling the graphql method, once the verification if the instance exists was happening after the assignment of the cancellableToken variable.
Description of changes
To work around this, I put the if statement that verificates if an instance was created into a method, in order to make it reusable. In this case, it was necessary to use it before the assignment of the cancellableToken variable.
Description of how you validated changes
[VScode debugger]
Code block behavior
without_isInstanceCreated.mp4
with_isInstanceCreated.mp4
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.