Skip to content

Commit 310cea9

Browse files
Update nuxt.md (#146)
1 parent 5d77cf3 commit 310cea9

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

docs/guide/nuxt.md

+13-7
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Vuex-ORM and Plugin GraphQL with Nuxt.
1010
```javascript
1111
export default {
1212
plugins: [
13-
'~/plugins/vuex-orm',
14-
'~/plugins/graphql'
13+
'~/plugins/graphql',
14+
'~/plugins/vuex-orm'
1515
]
1616
};
1717
```
@@ -60,11 +60,17 @@ import { HttpLink } from 'apollo-link-http';
6060
import fetch from 'node-fetch';
6161
import database from '~/data/database';
6262

63-
const options = { database, url: '...' };
63+
// The url can be anything, in this example we use the value from dotenv
64+
export default function({ app, env: { url } }) {
65+
const apolloClient = app?.apolloProvider?.defaultClient
66+
const options = { database, url };
6467

65-
if (process.server) {
66-
options.link = new HttpLink({ uri: options.url, fetch });
67-
}
68+
if (apolloClient) {
69+
options.apolloClient = apolloClient
70+
} else {
71+
options.link = new HttpLink({ uri: options.url, fetch });
72+
}
6873

69-
VuexORM.use(VuexORMGraphQL, options);
74+
VuexORM.use(VuexORMGraphQL, options);
75+
}
7076
```

0 commit comments

Comments
 (0)