Skip to content
Snippets Groups Projects
Commit 20b4219c authored by Pierre-Jean CHANCELLIER's avatar Pierre-Jean CHANCELLIER
Browse files

prepare fallbacks for graphQL API server

parent 51c800d3
No related branches found
No related tags found
No related merge requests found
......@@ -94,4 +94,6 @@ $ git push
Il suffit de créer un fichier `./pages/mapage.vue` pour que la nouvelle page soit accessible directement sur http://localhost/mapage. Pensez à insérer la logique pour le fil d'ariane dans ce fichier et à mettre à jour le menu dans la variable `menus` du fichier `./layouts/default.vue`. 3 pages d'exemple sont fournies pour montrer l'utilisation de l'API graphQL et de chartJS.
## GraphQL
Tout ce qui touche à GraphQL se trouve dans le dossier `./graphql`. Le fichier endpoints.js contient la liste des serveurs graphQL, le fichier queries.js contient toutes les requêtes de l'application.
\ No newline at end of file
All conf files for Apollo Graphql are stored in `./graphql`.
The file `queries.js` contains all queries.
If you want to add a 2nd graphQL server, edit the file `./graphql/clients/endpoints.js` to put your URL and uncomment the line concerning the `apollo.clientConfigs.myotherclient` option in `nuxt.config.js`. I have not tested this functionnality.
\ No newline at end of file
......@@ -3,7 +3,7 @@ import { setContext } from 'apollo-link-context'
import { from } from 'apollo-link'
import {ENDPOINT1} from './endpoints'
import {cache} from './cache'
import {cache} from '../cache'
export default ctx => {
const ssrMiddleware = setContext((_, { headers }) => {
......
module.exports = {
ENDPOINT1 : 'https://wwgql.coinduf.eu',
ENDPOINT2 : 'https://myserver.com'
}
\ No newline at end of file
import { HttpLink } from 'apollo-link-http'
import { setContext } from 'apollo-link-context'
import { from } from 'apollo-link'
import {ENDPOINT2} from './endpoints'
import {cache} from '../cache'
export default ctx => {
const ssrMiddleware = setContext((_, { headers }) => {
if (process.client) return headers
return {
headers
}
})
const httpLink = new HttpLink({
uri: ENDPOINT2
})
const link = from([ssrMiddleware, httpLink])
return {
link,
cache,
// https://github.com/nuxt-community/apollo-module/issues/306#issuecomment-607225431
defaultHttpLink: false
}
}
\ No newline at end of file
module.exports = {
ENDPOINT1 : 'https://wwgql.coinduf.eu'
}
\ No newline at end of file
const {ENDPOINT1} = require('./endpoints');
const {ENDPOINT1} = require('./clients/endpoints');
const fetch = require('node-fetch');
const fs = require('fs');
......
......@@ -79,7 +79,9 @@ export default {
apollo: {
clientConfigs: {
default: '~/graphql'
default: '~/graphql/clients/coindufeu'
//you can setup multiple clients with arbitrary names
//, myotherclient : '~/graphql/clients/otherclient'
},
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment