-
Notifications
You must be signed in to change notification settings - Fork 18
Composition API and Quasar v2 support #51
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
Comments
Just FYI, but we'll need Quasar on Vue3, before we change this AE. So, we are a while off, before that happens. Scott |
In the meantime, you can add the package Finaly, modify import { provide } from '@vue/composition-api'
import { DefaultApolloClient } from '@vue/apollo-composable'
...
export function apolloClientAfterCreate ({
apolloClient,
app,
//router, store, ssrContext, urlPath, redirect
}) {
app.setup = () => {
provide(DefaultApolloClient, apolloClient)
}
// if needed you can modify here the created apollo client
} For the moment, versions newer than You could also need the function import { isRef } from "@vue/composition-api";
import { createRef, Ref } from "@vue/composition-api/dist/reactivity";
export function toRef<T extends object, K extends keyof T>(object: T, key: K): Ref<T[K]> {
const v = object[key];
if (isRef<T[K]>(v)) return v;
return createRef({
get: () => object[key],
set: (v) => (object[key] = v),
});
} |
Hi, thanks for this really nice info! I tried to follow your instructions to backport "toRef" support by creating a file
VS Code does find that folder and doesn't show me an error. Just the command line compiler complains.. Any idea what's going on? |
Thanks @stphdenis for the integration hint. Btw.: There is no compatibility problem since version 4.0.0-alpha.10 of @vue/apollo-composable as mentioned here. |
@ejez - (and all) I'm going to be attacking this issue and creating version 2 in the next week or two, since Vue 3 is out and Quasar v2 is around the corner. Would you (anyone) be interested in some (more) collaboration? Scott |
Hello Scott |
@oliversteiner - Thanks for the offer. Are you on Discord? Ping me please Scott (EN-DE)#52 Scott |
Hey Scott i have made a Discord Account ( OliverSteiner#5240 ) Let's get in contact. |
@oliversteiner - Can you enter into the Quasar Discord server? Otherwise, I can't DM you or you me. 😁 Scott |
@oliversteiner - Did you miss the above? 😁 I've started work on v2 of the extension. I've got the composition API working, it's just not where I'd like it to be, as it seems, you can't cleanly hook into the root component's Scott |
Hi Scott, You'll get a warning: ...
import { ref, isRef, computed, watch,
// @ts-expect-error
-onServerPrefetch, getCurrentInstance, onBeforeUnmount, nextTick, } from 'vue-demi';
+getCurrentInstance, onBeforeUnmount, nextTick, } from 'vue-demi';
...
import { trackQuery } from './util/loadingTracking';
+const onServerPrefetch = null; |
For now, only vue apollo composition api is supported, also no ssr support... waiting for upstream projects... |
Yeah. I was that far too. 😁 https://github.com/smolinari/app-extension-apollo/tree/v2-work/src I'm sure your work is a step up from mine though. I'll test it tomorrow. Scott |
@ejez - Can we chat on Discord? Scott |
Your implementation compiles without issues but when I try to make a query with useQuery, I get this error:
|
@jvmonjo - Have to ask the stupid question, but did you follow the instructions in README.md? Scott |
Sure I have. But anyway my issue is in reference to @ejez/apollo implementation |
😁 - Yes, I am referring to the instructions in Ejez's repo. Scott |
Fair enough, 😁 No, I haven't. I thought they were the same. I will and I'll
post the results.
**Edit**: After making the change suggested in the readme I confirm `@ejez/apollo` works. Thanks.
|
Thanks for the feedback @jvmonjo |
What was it in the readme that resolved it for you? The only thing I didn't do was use the method of calling it all in one, I stuck with separate files for the gql:
Then call them from the file using it:
Didn't want to change everything to align it all in one file because it will get long and messy pretty quick. Added everything else as per the Readme though and still getting:
|
@Maggie0002 - which readme? 😁 Scott |
This one. |
Did you provide the Apollo client to the rest of your components from App.vue? |
Yep: https://github.com/LearnersBlock/library/blob/q2/src/App.vue |
Your project is Quasar v1, the above was for v2, follow this instead: #93 (comment) |
sorry was looking at the wrong branch, one sec ... |
Can you try to reproduce in a new clean project, so we can isolate the issue in an easier way... thx |
@ejez - Thanks for jumping in. Would you mind PRing your version into the repo? How about if we add a "next" branch and I'll remove the "v2-next" branch? Or just PR into that one? Not sure what would be easiest for you. Scott |
Hi Scott, will try to do it later today, either "next" or "v2" will do. (not both together) |
I prefer "v2", what do you think |
Seems like the issue is stemming from here, in App.vue:
It is executed right after Thanks for taking a look, and putting the time in to developing the extension. |
@ejez - Yeah, that is fine. v2 it is. 😁 Just have to figure out how to get the branch added, as I don't have full perms for the repo. Scott |
FYI, the next version (v2) is now in the v2 branch. Thanks goes to @ejez for his awesome work! Scott |
onServerPrefetch should now be resolved in the latest beta: vuejs/apollo#1102 (comment) |
Any update on getting apollo to quasar V2? |
https://github.com/quasarframework/app-extension-apollo/tree/v2 Scott |
v2 does not work. |
@hipertracker - It certainly works. You have a problem with your code or setup. Are you trying to call the client outside of a component? If yes, you have the answer in front of you. Scott |
@smolinari I am not trying to call the client outside of the component. To reproduce the bug I have created a new Quasar project and added a simple component. https://github.com/hipertracker/b8-frontend
|
@hipertracker - Not sure what to tell you. Everything works fine for me. You might want to try removing Scott |
@smolinari did you try this from scratch?
Have you not any Typescript warnings in the terminal, really? Has your Chrome browser not any errors in the Developer Tools? What Node are you using? I use 16.13.1 |
@hipertracker - By "works fine for me" I mean, it works fine in my project. You naturally have to set up the extension i.e. set up the apollo client and use your "options" properly to get everything to work. Scott |
@smolinari "it works in my project" sounds like nothing to me. I have created a sample project to reproduce the bug. Do you want to help or only to say f**k off? |
@hipertracker - I did download your reproduction repo and ran it before I made my last comment above. Your repo is not set up to do anything. Do some set up (use the options object and get the client options you need going) and if necessary, change Scott |
@hipertracker - Someone else just had the same problem as you were having and I believe it's a simple error of not adding the apollo boot file to I'm closing this issue too, as the OP is resolved in the end. Scott |
Uh oh!
There was an error while loading. Please reload this page.
The extension should probably support the Composition API of Vue Apollo, such as
useQuery
,useMutation
etc.https://v4.apollo.vuejs.org/api/use-query.html
I realize this is still only in alpha, so this issue is mostly for tracking.
The text was updated successfully, but these errors were encountered: