From 904e2a6efba917f325d2c208b404375b2e52c14f Mon Sep 17 00:00:00 2001 From: Nicolas Giard Date: Sun, 30 Sep 2018 14:20:26 -0400 Subject: [PATCH] fix: modules non-string config + live trail logging --- client/client-app.js | 17 ++++++++++- client/components/admin/admin-auth.vue | 2 +- client/components/admin/admin-groups-edit.vue | 13 ++++---- .../admin/admin-logging-console.vue | 27 +++++++++++++++-- client/components/admin/admin-logging.vue | 16 ++++++---- client/components/admin/admin-search.vue | 2 +- client/components/admin/admin-storage.vue | 2 +- .../logging-subscription-livetrail.gql | 7 +++++ package.json | 4 +++ server/graph/index.js | 30 ++++++++++++++++--- server/graph/resolvers/authentication.js | 2 +- server/graph/resolvers/logging.js | 5 ++++ server/graph/resolvers/search.js | 2 +- server/graph/resolvers/storage.js | 2 +- server/graph/schemas/common.graphql | 2 ++ server/graph/schemas/logging.graphql | 10 +++++++ server/master.js | 9 +++++- yarn.lock | 26 ++++++++-------- 18 files changed, 141 insertions(+), 37 deletions(-) create mode 100644 client/graph/admin/logging/logging-subscription-livetrail.gql diff --git a/client/client-app.js b/client/client-app.js index 6867cc2b..0bf9d238 100644 --- a/client/client-app.js +++ b/client/client-app.js @@ -8,8 +8,11 @@ import VeeValidate from 'vee-validate' import { ApolloClient } from 'apollo-client' import { createPersistedQueryLink } from 'apollo-link-persisted-queries' // import { BatchHttpLink } from 'apollo-link-batch-http' +import { split } from 'apollo-link' import { createHttpLink } from 'apollo-link-http' +import { WebSocketLink } from 'apollo-link-ws' import { InMemoryCache } from 'apollo-cache-inmemory' +import { getMainDefinition } from 'apollo-utilities' import VueApollo from 'vue-apollo' import Vuetify from 'vuetify' import Velocity from 'velocity-animate' @@ -48,6 +51,7 @@ moment.locale(siteConfig.lang) // ==================================== const graphQLEndpoint = window.location.protocol + '//' + window.location.host + '/graphql' +const graphQLWSEndpoint = ((window.location.protocol === 'https:') ? 'wss:' : 'ws:') + '//' + window.location.host + '/graphql-subscriptions' const graphQLLink = createPersistedQueryLink().concat( createHttpLink({ @@ -77,8 +81,19 @@ const graphQLLink = createPersistedQueryLink().concat( }) ) +const graphQLWSLink = new WebSocketLink({ + uri: graphQLWSEndpoint, + options: { + reconnect: true, + lazy: true + } +}) + window.graphQL = new ApolloClient({ - link: graphQLLink, + link: split(({ query }) => { + const { kind, operation } = getMainDefinition(query) + return kind === 'OperationDefinition' && operation === 'subscription' + }, graphQLWSLink, graphQLLink), cache: new InMemoryCache(), connectToDevTools: (process.env.node_env === 'development') }) diff --git a/client/components/admin/admin-auth.vue b/client/components/admin/admin-auth.vue index c83422fe..4777a81c 100644 --- a/client/components/admin/admin-auth.vue +++ b/client/components/admin/admin-auth.vue @@ -164,7 +164,7 @@ export default { 'selfRegistration', 'domainWhitelist', 'autoEnrollGroups' - ])).map(str => ({...str, config: str.config.map(cfg => ({...cfg, value: cfg.value.value}))})) + ])).map(str => ({...str, config: str.config.map(cfg => ({...cfg, value: JSON.stringify({ v: cfg.value.value })}))})) } }) this.$store.commit('showNotification', { diff --git a/client/components/admin/admin-groups-edit.vue b/client/components/admin/admin-groups-edit.vue index 04fde683..595a03b0 100644 --- a/client/components/admin/admin-groups-edit.vue +++ b/client/components/admin/admin-groups-edit.vue @@ -1,9 +1,12 @@