Skip to content

Commit 307e127

Browse files
committed
fix(nuxt-bridge): add support for nuxt bridge
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.
1 parent 83e4642 commit 307e127

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/templates/plugin.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default (ctx, inject) => {
2828
<% if (typeof options.clientConfigs[key] === 'object') { %>
2929
<%= key %>ClientConfig = <%= JSON.stringify(options.clientConfigs[key], null, 2) %>
3030
<% } else if (typeof options.clientConfigs[key] === 'string') { %>
31-
<%= key %>ClientConfig = require('<%= options.clientConfigs[key] %>')
31+
<%= key %>ClientConfig = import ('<%= options.clientConfigs[key] %>')
3232

3333
if ('default' in <%= key %>ClientConfig) {
3434
<%= key %>ClientConfig = <%= key %>ClientConfig.default
@@ -113,6 +113,7 @@ export default (ctx, inject) => {
113113
const apolloProvider = new VueApollo(vueApolloOptions)
114114
// Allow access to the provider in the context
115115
app.apolloProvider = apolloProvider
116+
inject('theApolloProvider', apolloProvider);
116117

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

0 commit comments

Comments
 (0)