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

Uncaught Error: Cannot detect villus Client, did you forget #172

Open
cworkschris opened this issue Sep 13, 2022 · 3 comments
Open

Uncaught Error: Cannot detect villus Client, did you forget #172

cworkschris opened this issue Sep 13, 2022 · 3 comments

Comments

@cworkschris
Copy link

cworkschris commented Sep 13, 2022

to call useClient? Alternatively, you can explicitly pass a client as the manualClient argument.

To start off, thank you logaretm! Villus looks really cool and since apollo does not seem to work via cdn, it really keeps the spirit alive of vue usable for any size project.

I'm trying to do a minimal proof of concept, following along https://gitmemories.com/logaretm/villus
Maybe I'm getting access to villus in the most awkward way possible, but what happens is the useClient is called successfully in the mounted() handling, but on the clickLoad handler I get "vue.global.js:1414 Uncaught Error: Cannot detect villus Client, did you forget to call useClient? Alternatively, you can explicitly pass a client as the manualClient argument."

I haven't messed around with the manualClient because it seems like I must be doing something fundamentally wrong. Am I way off in the weeds here?

I looked at the two comments where you explained that it can only be used during a composition api setup call. Will this not work at all when using options? I see this true: #72 (comment)
Oddly, even when I move over to composition api and use the <script setup> I'm still having this same problem. I can't find anything manualClient either.

@logaretm
Copy link
Owner

logaretm commented Sep 17, 2022

I checked your earlier snippets and there is an issue with it:

function mounted() {
 // too late to call this
  useClient({
    url: 'http://somemachine.local:8000/graphql',
  });
}

Instead, add a setup function and call it there on your app component:

const app = createApp({
  setup() {
    useClient({
      url: 'http://somemachine.local:8000/graphql',
    });
  }
}

It should work fine with the options API as it is just additive. I will probably need to add examples with the options API usage but it would be very limited.

@cworkschris
Copy link
Author

cworkschris commented Sep 22, 2022 via email

@logaretm
Copy link
Owner

Sorry for the late response. Perhaps there are a couple of Vue installations competing here. Can you create a minimal repo for it where this happens?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants