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

correcting bugs

parent af43314d
No related branches found
No related tags found
No related merge requests found
Showing
with 88 additions and 51 deletions
......@@ -50,7 +50,7 @@ The schema documentation is stored in the `./graphql/doc/graphQLschema.txt` file
In `queries.js` you'll find all queries.
If you want to add a 2nd graphQL server, edit `./graphql/endpoints.js` to put your URL.
If you want to add a graphQL server, add a file in `./graphql/endpoints/` and edit `./nuxt.config.js` to add an entry in `apollo.clientConfigs` for your file.
### Special Directories
......
......@@ -4,7 +4,7 @@
class="form-select"
id="selectClient"
@change="setClient($event)"
v-model="currentClient">
v-model="getApolloClient">
<option
:value="clientName"
v-for="(clientObject, clientName) in $nuxt.$apolloProvider.clients"
......@@ -23,15 +23,11 @@
<script>
export default {
data() {
return {
currentClient: this.$getApolloClient()
}
},
methods: {
setClient(e) {
localStorage.setItem("apollo-client", e.target.value)
location.assign(this.$i18n.locale + "/index.html")
window.location =
window.location.origin + "/" + this.$i18n.locale + "/index.html"
}
}
}
......
......@@ -82,7 +82,7 @@ export default {
},
apollo: {
$client() {
return this.$getApolloClient()
return this.getApolloClient
},
countMax: {
query: LAST_BLOCK
......
import {
InMemoryCache,
IntrospectionFragmentMatcher,
defaultDataIdFromObject
} from "apollo-cache-inmemory"
......@@ -9,7 +10,7 @@ const fragmentMatcher = new IntrospectionFragmentMatcher({
})
// Apparemment il faut utiliser la syntaxe Apollo v2
export const cache = {
export const cache = new InMemoryCache({
addTypename: false,
fragmentMatcher,
dataIdFromObject: (object) => {
......@@ -34,4 +35,4 @@ export const cache = {
return defaultDataIdFromObject(object) // fall back to default handling
}
}
}
})
import { cache } from "./cache"
import * as endpoints from "./endpoints"
let clientConfigs = {}
for (const key in endpoints) {
if (key != "default")
clientConfigs[key] = {
httpEndpoint: endpoints[key],
inMemoryCacheOptions: cache,
httpLinkOptions: {
credentials: "same-origin"
}
}
}
export default { clientConfigs }
module.exports = {
coindufEu: "https://wwgql.coinduf.eu",
trentesauxFr: "https://gql.wotwizard.trentesaux.fr/"
}
import { HttpLink } from "apollo-link-http"
import { setContext } from "apollo-link-context"
import { from } from "apollo-link"
import { cache } from "../cache"
export default (ctx) => {
const ssrMiddleware = setContext((_, { headers }) => {
if (process.client) return headers
return {
headers
}
})
const httpLink = new HttpLink({
uri: "https://wwgql.coinduf.eu"
})
const link = from([ssrMiddleware, httpLink])
return {
link,
cache,
// https://github.com/nuxt-community/apollo-module/issues/306#issuecomment-607225431
defaultHttpLink: false
}
}
import { HttpLink } from "apollo-link-http"
import { setContext } from "apollo-link-context"
import { from } from "apollo-link"
import { cache } from "../cache"
export default (ctx) => {
const ssrMiddleware = setContext((_, { headers }) => {
if (process.client) return headers
return {
headers
}
})
const httpLink = new HttpLink({
uri: "https://gql.wotwizard.trentesaux.fr/"
})
const link = from([ssrMiddleware, httpLink])
return {
link,
cache,
// https://github.com/nuxt-community/apollo-module/issues/306#issuecomment-607225431
defaultHttpLink: false
}
}
const endpoints = require("./endpoints")
const fetch = require("node-fetch")
const fs = require("fs")
fetch(Object.values(endpoints)[0], {
fetch("https://gql.wotwizard.trentesaux.fr/", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
......
import i18n from "./i18n"
import APOLLO_CONFIG from "./graphql/config"
export default {
// Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
......@@ -126,7 +125,12 @@ export default {
}
},
apollo: APOLLO_CONFIG,
apollo: {
clientConfigs: {
coindufeu: "~/graphql/endpoints/coindufeu",
trentesaux: "~/graphql/endpoints/trentesaux"
}
},
router: {
linkExactActiveClass: "active"
......
{
"name": "wotwizard-ui",
"version": "2.4.1",
"version": "2.4.2",
"private": true,
"scripts": {
"dev": "nuxt",
......
......@@ -75,7 +75,7 @@ export default {
},
apollo: {
$client() {
return this.$getApolloClient()
return this.getApolloClient
},
favoris: {
query: FAVORIS,
......
......@@ -78,7 +78,7 @@ export default {
},
apollo: {
$client() {
return this.$getApolloClient()
return this.getApolloClient
},
newMembers: {
query: LAST_EVENTS,
......
......@@ -45,7 +45,7 @@ export default {
},
apollo: {
$client() {
return this.$getApolloClient()
return this.getApolloClient
},
idFromHash: {
query: SEARCH_MEMBER,
......
......@@ -59,7 +59,7 @@ export default {
},
apollo: {
$client() {
return this.$getApolloClient()
return this.getApolloClient
},
idSearch: {
query: SEARCH_MEMBERS,
......
......@@ -88,7 +88,7 @@ export default {
},
apollo: {
$client() {
return this.$getApolloClient()
return this.getApolloClient
},
allParameters: {
query: PARAMS,
......
......@@ -199,7 +199,7 @@ export default {
},
apollo: {
$client() {
return this.$getApolloClient()
return this.getApolloClient
},
wwResult: {
query: NEWCOMERS,
......
......@@ -89,7 +89,7 @@ export default {
},
apollo: {
$client() {
return this.$getApolloClient()
return this.getApolloClient
},
memEnds: {
query: NEXT_EXITS,
......
import * as endpoints from "../graphql/endpoints"
import Vue from "vue"
export default ({ app }, inject) => {
inject(
"getApolloClient",
() => localStorage.getItem("apollo-client") || Object.keys(endpoints)[0]
)
let mixin = {
computed: {
getApolloClient() {
return (
localStorage.getItem("apollo-client") ||
Object.keys($nuxt.$apolloProvider.clients)[0]
)
}
}
}
Vue.mixin(mixin)
......@@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Wotwizard UI",
"description": "Le magicien de la toile de confiance",
"version": "2.4.1",
"version": "2.4.2",
"homepage_url": "https://wotwizard.axiom-team.fr",
"browser_action": {
"browser_style": true,
......
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