-
Notifications
You must be signed in to change notification settings - Fork 110
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
docs: Add example for Apollo GraphQL + composition API #192
Conversation
Oops. Some tests are failing with |
Hi, thanks for this!! 🎉 this is great, it was one of the missing pieces to make sure VTL can support Vue 3, and I'm not experienced enough when it comes to vue apollo to make it work.
It does exist: https://vue-test-utils.vuejs.org/v2/api/#global-provide |
I actually tried that but it didn't work. Maybe you can help to understand why... |
Happy if I can help with something else 😊 |
Sure! Can you share what failed? I'm also on the VTU team so I can run the issue internally if needed 👍 |
If, instead of using render(Component, {
props: {id: '1'},
global: {
provide: {
DefaultApolloClient: apolloClient,
}
}
}) the apollo client won't be injected and you'll get this error when running the test:
|
You should have something like this 👇 instead: import { DefaultApolloClient } from '@vue/apollo-composable'
...
render(Component, {
props: {id: '1'},
global: {
provide: {
[DefaultApolloClient]: apolloClient,
}
}
}) NB: I can prepare another PR if needed. |
@agualis @afontcu You should refer to this Vue 3 Project Template for proper testing infrastructure support using |
Oh. I missed that I needed square brackets because
I looks good. Thanks for sharing. |
I recall that I had to use a fixed I'll try to reproduce it in another machine. It's funny that we are also having a different error in GHA CI 😅 (bug fragmentation 🤣 ). |
@agualis I will like you to invite me to the repository you are working on because I'm able to resolve the failing tests and I don't want to create a separate PR for this project or for your fork. see loom recording below: https://www.loom.com/share/abf53aaedce448d89564afc22c1ebfcf cc: @afontcu |
I'm not sure if I'm following you @heywhy I don't have another project, just the fork. |
I don't want to create another fork of this project instead I want to push the changes directly to your own fork because I made the fixes on your fork but I don't have access to your fork so I can't push the changes. I hope that's clear |
Looks like this PR contains changes that are already there in |
@afontcu I don't understand why the CI fails, can you help delete the cache for this PR workflow |
Codecov Report
@@ Coverage Diff @@
## next #192 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 91 91
Branches 30 30
=========================================
Hits 91 91 Continue to review full report at Codecov.
|
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.
Glad you got CI working! Looks mergeable, right?
@agualis can you explain what went wrong?? |
Finally ready to merge 🎊 . It seems that @heywhy I enabled CI in my fork and I discovered that version 3.2.2 of @afontcu will keep an eye on this topic because apollo related dependencies will be fixed soon and we will be able to get rid of the nasty Thanks both for your patience and help 🙏 |
Looks great :) Thank you for this! |
🎉 This PR is included in version 6.3.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Updates the existing
Graphql
example to make it compatible withVue 3
+@vue/apollo-composable
.The example needs a temporary patch until a pending PR is merged in
vue-apollo
project. That's why we have to use specific"@vue/apollo-composable": "4.0.0-alpha.10"
version for now.Implementation detail:
I had to create a wrapper component
ComponentWithInjectedApollo
to globally provide apollo client in the test. I would prefer not to do it and use some VTU option to callglobal.provide
but I didn't find that option 🤷 Maybe you know how to do it.Bonus: I could add an additional test to check what happens when the Graphql request returns an error (It would involve adding some kind of error handling to the
VueApollo.vue
component).