Skip to content

Commit 5075f4b

Browse files
author
Guillaume Chau
committed
refactor(ui): update to vue-cli-plugin-apollo 0.10
1 parent de49111 commit 5075f4b

File tree

8 files changed

+24
-68
lines changed

8 files changed

+24
-68
lines changed

packages/@vue/cli-ui/.env.production

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VUE_APP_GRAPHQL_ENDPOINT=
1+
VUE_APP_GRAPHQL_WS=

packages/@vue/cli-ui/package.json

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
"lint": "vue-cli-service lint",
88
"graphql-api": "cross-env VUE_CLI_DEBUG=true vue-cli-service graphql-api",
99
"run-graphql-api": "vue-cli-service run-graphql-api",
10-
"run-test-graphql-api": "cross-env NODE_ENV=test yarn run graphql-api",
10+
"run-test-graphql-api": "cross-env NODE_ENV=test VUE_APP_GRAPHQL_PORT=4040 VUE_APP_GRAPHQL_WS=ws://localhost:4040/graphql yarn run graphql-api",
1111
"prepublishOnly": "yarn run lint --no-fix && yarn run build",
12-
"test:e2e:dev": "vue-cli-service test:e2e --mode development",
13-
"test:e2e:run": "vue-cli-service test:e2e --mode production --headless --url=http://localhost:4000",
14-
"test:e2e": "start-server-and-test run-test-graphql-api http://localhost:4000 test:e2e:dev",
15-
"test:run": "start-server-and-test run-test-graphql-api http://localhost:4000 test:e2e:run",
12+
"test:e2e:dev": "cross-env VUE_APP_GRAPHQL_WS=ws://localhost:4040/graphql vue-cli-service test:e2e --mode development",
13+
"test:e2e:run": "vue-cli-service test:e2e --mode production --headless --url=http://localhost:4040",
14+
"test:e2e": "start-server-and-test run-test-graphql-api http://localhost:4040 test:e2e:dev",
15+
"test:run": "start-server-and-test run-test-graphql-api http://localhost:4040 test:e2e:run",
1616
"test": "yarn run build && cd ../cli-ui-addon-webpack && yarn run build && cd ../cli-ui && yarn run test:run"
1717
},
1818
"dependencies": {
@@ -31,7 +31,7 @@
3131
"semver": "^5.5.0",
3232
"shortid": "^2.2.8",
3333
"terminate": "^2.1.0",
34-
"vue-cli-plugin-apollo": "^0.8.0",
34+
"vue-cli-plugin-apollo": "^0.10.0",
3535
"watch": "^1.0.2"
3636
},
3737
"devDependencies": {
@@ -42,19 +42,13 @@
4242
"@vue/eslint-config-standard": "^3.0.0-beta.11",
4343
"@vue/ui": "^0.2.5",
4444
"ansi_up": "^2.0.2",
45-
"apollo-cache-inmemory": "^1.1.10",
46-
"apollo-client": "^2.2.6",
47-
"apollo-link": "^1.2.1",
48-
"apollo-link-state": "^0.4.0",
49-
"apollo-link-ws": "^1.0.0",
5045
"cross-env": "^5.1.5",
5146
"eslint": "^4.16.0",
5247
"file-icons-js": "^1.0.3",
5348
"lint-staged": "^6.0.0",
5449
"start-server-and-test": "^1.4.1",
5550
"stylus": "^0.54.5",
5651
"stylus-loader": "^3.0.1",
57-
"subscriptions-transport-ws": "^0.9.9",
5852
"vue": "^2.5.16",
5953
"vue-apollo": "^3.0.0-beta.5",
6054
"vue-color": "^2.4.6",

packages/@vue/cli-ui/src/apollo.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

packages/@vue/cli-ui/src/graphql-api/connectors/client-addons.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ const { resolveModuleRoot } = require('../utils/resolve-path')
66

77
let addons = []
88

9-
let baseUrl = process.env.VUE_APP_GRAPHQL_ENDPOINT
10-
if (typeof baseUrl === 'undefined') baseUrl = 'http://localhost:4000'
9+
let baseUrl = process.env.VUE_APP_GRAPHQL_WS
10+
if (typeof baseUrl === 'undefined') {
11+
baseUrl = 'http://localhost:4000'
12+
} else {
13+
baseUrl = baseUrl.replace(/ws:\/\/([a-z0-9_-]+:\d+).*/i, 'http://$1')
14+
}
1115

1216
function list (context) {
1317
return addons

packages/@vue/cli-ui/src/state/defaults.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/@vue/cli-ui/src/state/resolvers.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/@vue/cli-ui/src/vue-apollo.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
import Vue from 'vue'
22
import VueApollo from 'vue-apollo'
3-
import createApolloClient from './apollo'
3+
import { createApolloClient } from 'vue-cli-plugin-apollo/graphql-client'
44

55
// Install the vue plugin
66
Vue.use(VueApollo)
77

8-
let base = process.env.VUE_APP_GRAPHQL_ENDPOINT
9-
if (typeof base === 'undefined') {
10-
base = 'http://localhost:4000'
11-
} else if (base === '') {
12-
base = window.location.origin
8+
let endpoint = process.env.VUE_APP_GRAPHQL_WS
9+
if (typeof endpoint === 'undefined') {
10+
endpoint = 'ws://localhost:4000/graphql'
11+
} else if (endpoint === '') {
12+
endpoint = window.location.origin.replace('http', 'ws') + '/graphql'
1313
}
1414

1515
// Config
1616
const options = {
17-
base,
18-
endpoints: {
19-
graphql: process.env.VUE_APP_GRAPHQL_PATH || '/graphql',
20-
subscription: process.env.VUE_APP_GRAPHQL_SUBSCRIPTIONS_PATH || '/graphql'
21-
},
22-
persisting: false
17+
wsEndpoint: endpoint,
18+
persisting: false,
19+
websocketsOnly: true
2320
}
2421

2522
// Create apollo client
26-
export const apolloClient = createApolloClient(options)
23+
export const { apolloClient } = createApolloClient(options)
2724

2825
// Create vue apollo provider
2926
export const apolloProvider = new VueApollo({

packages/@vue/cli/lib/ui.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ async function ui (options = {}, context = process.cwd()) {
99

1010
// Config
1111
process.env.VUE_APP_GRAPHQL_PORT = port
12-
process.env.VUE_APP_GRAPHQL_ENDPOINT = ''
12+
process.env.VUE_APP_GRAPHQL_WS = ''
1313
process.env.VUE_APP_GRAPHQL_PLAYGROUND_PATH = '/graphql-playground'
1414

1515
if (!options.dev) {

0 commit comments

Comments
 (0)