Skip to content

Commit

Permalink
fix(nuxt-bridge): add support for nuxt bridge
Browse files Browse the repository at this point in the history
Nuxt Bridge exposes the Nuxt 2 context via nuxtApp.nuxt2Context.

However, when doing `app.apolloProvider`, the apolloProvider is not added to this context.

In order to get the apolloProvider onto this nuxt2Context, we must use inject().

However, it requires a different name than "apolloProvider" when injecting, or we get errors.
  • Loading branch information
Jamiewarb committed Dec 20, 2021
1 parent 83e4642 commit 307e127
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/templates/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default (ctx, inject) => {
<% if (typeof options.clientConfigs[key] === 'object') { %>
<%= key %>ClientConfig = <%= JSON.stringify(options.clientConfigs[key], null, 2) %>
<% } else if (typeof options.clientConfigs[key] === 'string') { %>
<%= key %>ClientConfig = require('<%= options.clientConfigs[key] %>')
<%= key %>ClientConfig = import ('<%= options.clientConfigs[key] %>')

if ('default' in <%= key %>ClientConfig) {
<%= key %>ClientConfig = <%= key %>ClientConfig.default
Expand Down Expand Up @@ -113,6 +113,7 @@ export default (ctx, inject) => {
const apolloProvider = new VueApollo(vueApolloOptions)
// Allow access to the provider in the context
app.apolloProvider = apolloProvider
inject('theApolloProvider', apolloProvider);

if (process.server) {
const ApolloSSR = require('vue-apollo/ssr')
Expand Down

0 comments on commit 307e127

Please sign in to comment.