chore: refactor eslint config
This commit is contained in:
@@ -44,12 +44,10 @@ jobs:
|
||||
key: v10-dependencies-{{ checksum "yarn.lock" }}
|
||||
|
||||
# run tests!
|
||||
- run: yarn lint
|
||||
- run: yarn build
|
||||
- run: cd packages/vue-apollo-option && yarn lint
|
||||
- run: cd packages/vue-apollo-option && yarn test:types
|
||||
- run: cd packages/vue-apollo-option && yarn test:unit
|
||||
- run: cd packages/vue-apollo-components && yarn lint
|
||||
- run: cd packages/vue-apollo-composable && yarn lint
|
||||
- run: cd packages/vue-apollo-composable && yarn test:types
|
||||
- run: cd packages/test-e2e && yarn test:e2e
|
||||
- run: cd packages/test-e2e-composition && yarn test:e2e
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
env: {
|
||||
browser: true,
|
||||
},
|
||||
extends: [
|
||||
'plugin:vue/recommended',
|
||||
'@vue/standard',
|
||||
'@vue/typescript/recommended',
|
||||
],
|
||||
parserOptions: {
|
||||
ecmaVersion: 2020,
|
||||
},
|
||||
globals: {
|
||||
name: 'off',
|
||||
},
|
||||
rules: {
|
||||
'vue/html-closing-bracket-newline': [
|
||||
'error',
|
||||
{
|
||||
singleline: 'never',
|
||||
multiline: 'always',
|
||||
},
|
||||
],
|
||||
'no-var': ['error'],
|
||||
'@typescript-eslint/member-delimiter-style': [
|
||||
'error',
|
||||
{
|
||||
multiline: {
|
||||
delimiter: 'none',
|
||||
},
|
||||
singleline: {
|
||||
delimiter: 'comma',
|
||||
},
|
||||
},
|
||||
],
|
||||
'@typescript-eslint/no-use-before-define': 'off',
|
||||
'comma-dangle': ['error', 'always-multiline'],
|
||||
'vue/no-multiple-template-root': 'off',
|
||||
indent: 'off',
|
||||
'@typescript-eslint/indent': ['error', 2],
|
||||
quotes: ['error', 'single', { allowTemplateLiterals: true }],
|
||||
'no-use-before-define': 'warn',
|
||||
'accessor-pairs': 'off',
|
||||
'no-async-promise-executor': 'off',
|
||||
'@typescript-eslint/no-empty-function': 'warn',
|
||||
'no-return-assign': 'off',
|
||||
'multiline-ternary': 'off',
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.vue'],
|
||||
rules: {
|
||||
'@typescript-eslint/no-unused-vars': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
files: [
|
||||
'packages/*/server.js',
|
||||
'packages/*/apollo.config.js',
|
||||
'packages/*/apollo-server/**/*',
|
||||
'packages/*/tests/**/*.js',
|
||||
'packages/*/build/**/*.js',
|
||||
'packages/*/lib/**/*.js',
|
||||
],
|
||||
rules: {
|
||||
'@typescript-eslint/no-var-requires': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
files: [
|
||||
'**/*.test.ts',
|
||||
'packages/*/types/test/**/*.ts',
|
||||
],
|
||||
rules: {
|
||||
camelcase: 'off',
|
||||
'no-unused-expressions': 'off',
|
||||
'array-callback-return': 'warn',
|
||||
},
|
||||
},
|
||||
],
|
||||
ignorePatterns: [
|
||||
'node_modules/',
|
||||
'dist/',
|
||||
'generated/',
|
||||
'!.*',
|
||||
'schema.graphql',
|
||||
],
|
||||
}
|
||||
+13
-2
@@ -8,14 +8,25 @@
|
||||
"scripts": {
|
||||
"build": "lerna run build --concurrency 1 --scope \"{vue-apollo,@vue/apollo}*\"",
|
||||
"test": "lerna run test --concurrency 1",
|
||||
"lint": "lerna run lint",
|
||||
"lint": "eslint . --ext js,vue,ts",
|
||||
"release": "lerna publish"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^4.2.0",
|
||||
"@typescript-eslint/parser": "^4.2.0",
|
||||
"@vue/eslint-config-standard": "^6.0.0",
|
||||
"@vue/eslint-config-typescript": "^7.0.0",
|
||||
"core-js": "^3.4.1",
|
||||
"esbuild": "^0.8.44",
|
||||
"esbuild-node-externals": "^1.0.2",
|
||||
"lerna": "^3.18.4"
|
||||
"eslint": "^7.19.0",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-promise": "^4.2.1",
|
||||
"eslint-plugin-standard": "^5.0.0",
|
||||
"eslint-plugin-vue": "^7.5.0",
|
||||
"lerna": "^3.18.4",
|
||||
"typescript": "^4.1.5"
|
||||
},
|
||||
"resolutions": {
|
||||
"eslint-scope": "^5.0.0",
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
<template>
|
||||
<p class="sponsor-button">
|
||||
<github-button href="https://github.com/sponsors/Akryum" data-icon="octicon-heart" data-size="large" aria-label="Sponsor @Akryum on GitHub">
|
||||
<github-button
|
||||
href="https://github.com/sponsors/Akryum"
|
||||
data-icon="octicon-heart"
|
||||
data-size="large"
|
||||
aria-label="Sponsor @Akryum on GitHub"
|
||||
>
|
||||
Sponsor on GitHub
|
||||
</github-button>
|
||||
</p>
|
||||
@@ -11,8 +16,8 @@ import GithubButton from 'vue-github-button'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
GithubButton
|
||||
}
|
||||
GithubButton,
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -20,4 +25,4 @@ export default {
|
||||
.sponsor-button
|
||||
text-align center
|
||||
margin 24px 0
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -14,15 +14,15 @@ module.exports = {
|
||||
lang: 'zh-CN',
|
||||
title: 'Vue Apollo',
|
||||
description: '🚀 在你的 Vue.js 应用中集成 GraphQL!',
|
||||
}
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
'@vuepress/pwa': {
|
||||
serviceWorker: true,
|
||||
updatePopup: {
|
||||
'/': {
|
||||
message: "New content is available.",
|
||||
buttonText: "Refresh"
|
||||
message: 'New content is available.',
|
||||
buttonText: 'Refresh',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
dist/
|
||||
@@ -1,20 +0,0 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
env: {
|
||||
node: true
|
||||
},
|
||||
extends: [
|
||||
'plugin:vue/vue3-essential',
|
||||
'@vue/standard',
|
||||
'@vue/typescript/recommended'
|
||||
],
|
||||
parserOptions: {
|
||||
ecmaVersion: 2020
|
||||
},
|
||||
rules: {
|
||||
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
||||
'comma-dangle': ['error', 'always-multiline'],
|
||||
'@typescript-eslint/no-var-requires': 'off',
|
||||
}
|
||||
}
|
||||
@@ -20,10 +20,5 @@ yarn build
|
||||
yarn test:e2e
|
||||
```
|
||||
|
||||
### Lints and fixes files
|
||||
```
|
||||
yarn lint
|
||||
```
|
||||
|
||||
### Customize configuration
|
||||
See [Configuration Reference](https://cli.vuejs.org/config/).
|
||||
|
||||
@@ -5,11 +5,10 @@
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"test": "yarn run lint --no-fix && yarn run test:e2e",
|
||||
"test": "yarn run test:e2e",
|
||||
"test:e2e": "start-server-and-test api http://localhost:4042/.well-known/apollo/server-health test:e2e:client",
|
||||
"test:e2e:client": "vue-cli-service test:e2e --mode production --headless",
|
||||
"test:e2e:dev": "vue-cli-service test:e2e",
|
||||
"lint": "vue-cli-service lint",
|
||||
"api": "node server.js"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -27,25 +26,13 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/shortid": "^0.0.29",
|
||||
"@typescript-eslint/eslint-plugin": "^2.33.0",
|
||||
"@typescript-eslint/parser": "^2.33.0",
|
||||
"@vue/cli-plugin-babel": "~4.5.0",
|
||||
"@vue/cli-plugin-e2e-cypress": "~4.5.0",
|
||||
"@vue/cli-plugin-eslint": "~4.5.0",
|
||||
"@vue/cli-plugin-typescript": "~4.5.0",
|
||||
"@vue/cli-service": "~4.5.0",
|
||||
"@vue/compiler-sfc": "^3.0.0",
|
||||
"@vue/eslint-config-standard": "^5.1.2",
|
||||
"@vue/eslint-config-typescript": "^5.0.2",
|
||||
"axios": "^0.20.0",
|
||||
"eslint": "^6.7.2",
|
||||
"eslint-plugin-import": "^2.20.2",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-promise": "^4.2.1",
|
||||
"eslint-plugin-standard": "^4.0.0",
|
||||
"eslint-plugin-vue": "^7.0.0-0",
|
||||
"start-server-and-test": "^1.10.6",
|
||||
"tailwindcss": "^1.0.1",
|
||||
"typescript": "^4.0.3"
|
||||
"tailwindcss": "^1.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="flex h-screen items-stretch bg-gray-100">
|
||||
<ChannelList class="w-1/4 border-r border-gray-200" />
|
||||
<router-view class="flex-1 overflow-auto"/>
|
||||
<router-view class="flex-1 overflow-auto" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ import { useQuery, useResult } from '@vue/apollo-composable'
|
||||
import { defineComponent } from 'vue'
|
||||
|
||||
interface Channel {
|
||||
id: string;
|
||||
label: string;
|
||||
id: string
|
||||
label: string
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
@@ -29,14 +29,21 @@ export default defineComponent({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="loading" class="p-12 text-gray-500">
|
||||
<div
|
||||
v-if="loading"
|
||||
class="p-12 text-gray-500"
|
||||
>
|
||||
Loading channels...
|
||||
</div>
|
||||
|
||||
<div v-else class="flex flex-col bg-white">
|
||||
<div
|
||||
v-else
|
||||
class="flex flex-col bg-white"
|
||||
>
|
||||
<router-link
|
||||
v-for="channel of channels"
|
||||
:key="channel.id"
|
||||
v-slot="{ href, navigate, isActive }"
|
||||
:to="{
|
||||
name: 'channel',
|
||||
params: {
|
||||
@@ -44,7 +51,6 @@ export default defineComponent({
|
||||
},
|
||||
}"
|
||||
custom
|
||||
#default="{ href, navigate, isActive }"
|
||||
>
|
||||
<a
|
||||
:href="href"
|
||||
|
||||
@@ -60,14 +60,22 @@ export default defineComponent({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="loading">Loading channel...</div>
|
||||
<div v-if="loading">
|
||||
Loading channel...
|
||||
</div>
|
||||
|
||||
<div v-else class="flex flex-col">
|
||||
<div
|
||||
v-else
|
||||
class="flex flex-col"
|
||||
>
|
||||
<div class="flex-none p-6 border-b border-gray-200 bg-white">
|
||||
Currently viewing # {{ channel.label }}
|
||||
</div>
|
||||
|
||||
<div ref="messagesEl" class="flex-1 overflow-y-auto">
|
||||
<div
|
||||
ref="messagesEl"
|
||||
class="flex-1 overflow-y-auto"
|
||||
>
|
||||
<MessageItem
|
||||
v-for="message of channel.messages"
|
||||
:key="message.id"
|
||||
@@ -77,7 +85,7 @@ export default defineComponent({
|
||||
</div>
|
||||
|
||||
<MessageForm
|
||||
:channelId="channel.id"
|
||||
:channel-id="channel.id"
|
||||
class="flex-none m-2 mt-0"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -22,12 +22,19 @@ export default defineComponent({
|
||||
|
||||
<template>
|
||||
<div class="m-6">
|
||||
<button class="bg-green-200 rounded-lg p-4" @click="load()">
|
||||
<button
|
||||
class="bg-green-200 rounded-lg p-4"
|
||||
@click="load()"
|
||||
>
|
||||
Load list
|
||||
</button>
|
||||
|
||||
<ul class="my-4">
|
||||
<li v-for="(item, index) of list" :key="index" class="list-disc ml-6">
|
||||
<li
|
||||
v-for="(item, index) of list"
|
||||
:key="index"
|
||||
class="list-disc ml-6"
|
||||
>
|
||||
{{ item }}
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
module.exports = {
|
||||
plugins: [
|
||||
'cypress'
|
||||
'cypress',
|
||||
],
|
||||
env: {
|
||||
mocha: true,
|
||||
'cypress/globals': true
|
||||
'cypress/globals': true,
|
||||
},
|
||||
rules: {
|
||||
strict: 'off'
|
||||
}
|
||||
strict: 'off',
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
schema.graphql
|
||||
dist/
|
||||
@@ -1,31 +0,0 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
|
||||
env: {
|
||||
node: true,
|
||||
},
|
||||
|
||||
'extends': [
|
||||
'plugin:vue/recommended',
|
||||
'@vue/standard',
|
||||
],
|
||||
|
||||
rules: {
|
||||
'graphql/template-strings': [
|
||||
'error',
|
||||
{
|
||||
env: 'literal',
|
||||
projectName: 'app',
|
||||
},
|
||||
],
|
||||
'comma-dangle': ['error', 'always-multiline'],
|
||||
},
|
||||
|
||||
parserOptions: {
|
||||
parser: 'babel-eslint',
|
||||
},
|
||||
|
||||
plugins: [
|
||||
'graphql',
|
||||
],
|
||||
}
|
||||
@@ -7,8 +7,8 @@ const messages = [
|
||||
userId: '__bot',
|
||||
channelId: 'general',
|
||||
content: 'Welcome to the chat!',
|
||||
dateAdded: Date.now()
|
||||
}
|
||||
dateAdded: Date.now(),
|
||||
},
|
||||
]
|
||||
|
||||
function publishChange ({ type, message }, context) {
|
||||
|
||||
@@ -6,8 +6,8 @@ const users = [
|
||||
email: 'bot@bot.com',
|
||||
password: 'bot',
|
||||
nickname: 'The Bot',
|
||||
tokens: []
|
||||
}
|
||||
tokens: [],
|
||||
},
|
||||
]
|
||||
|
||||
exports.register = (input, context) => {
|
||||
@@ -24,7 +24,7 @@ exports.register = (input, context) => {
|
||||
nickname: input.nickname,
|
||||
tokens: [],
|
||||
})
|
||||
|
||||
|
||||
resolve(true)
|
||||
}, 100)
|
||||
})
|
||||
@@ -32,7 +32,7 @@ exports.register = (input, context) => {
|
||||
|
||||
exports.login = ({ email, password }, context) => {
|
||||
const user = users.find(
|
||||
u => u.email === email && u.password === password
|
||||
u => u.email === email && u.password === password,
|
||||
)
|
||||
if (!user) throw new Error('User not found')
|
||||
const token = {
|
||||
|
||||
@@ -51,14 +51,14 @@ module.exports = {
|
||||
messageChanged: {
|
||||
subscribe: withFilter(
|
||||
(parent, args, { pubsub }) => pubsub.asyncIterator(triggers.MESSAGE_CHANGED),
|
||||
(payload, vars) => payload.messageChanged.message.channelId === vars.channelId
|
||||
(payload, vars) => payload.messageChanged.message.channelId === vars.channelId,
|
||||
),
|
||||
},
|
||||
|
||||
counterUpdated: {
|
||||
subscribe: withFilter(
|
||||
(parent, args, { pubsub }) => pubsub.asyncIterator('counter'),
|
||||
(payload, vars) => payload.type === vars.type
|
||||
(payload, vars) => payload.type === vars.type,
|
||||
),
|
||||
},
|
||||
},
|
||||
|
||||
@@ -5,10 +5,9 @@
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"lint": "vue-cli-service lint",
|
||||
"apollo:dev": "vue-cli-service apollo:dev",
|
||||
"apollo:start": "vue-cli-service apollo:start --port 4042",
|
||||
"test": "yarn run lint --no-fix && yarn run test:e2e",
|
||||
"test": "yarn run test:e2e",
|
||||
"test:e2e": "start-server-and-test apollo:start http://localhost:4042/.well-known/apollo/server-health test:e2e:client",
|
||||
"test:e2e:client": "vue-cli-service test:e2e --mode production --headless",
|
||||
"test:e2e:dev": "start-server-and-test apollo:dev http://localhost:4042/.well-known/apollo/server-health test:e2e:dev:client",
|
||||
@@ -29,13 +28,7 @@
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-babel": "^4.0.4",
|
||||
"@vue/cli-plugin-e2e-cypress": "^4.0.4",
|
||||
"@vue/cli-plugin-eslint": "^4.0.4",
|
||||
"@vue/cli-service": "^4.0.4",
|
||||
"@vue/eslint-config-standard": "^4.0.0",
|
||||
"babel-eslint": "^10.0.3",
|
||||
"eslint": "^4.19.1",
|
||||
"eslint-plugin-graphql": "^3.1.0",
|
||||
"eslint-plugin-vue": "^5.2.3",
|
||||
"graphql-tag": "^2.5.0",
|
||||
"start-server-and-test": "^1.10.6",
|
||||
"stylus": "^0.54.5",
|
||||
|
||||
@@ -74,7 +74,7 @@ export default {
|
||||
}))
|
||||
|
||||
async function scrollToBottom (force = false) {
|
||||
let el = body.value
|
||||
const el = body.value
|
||||
|
||||
// No body element yet
|
||||
if (!el) {
|
||||
|
||||
@@ -25,15 +25,17 @@ export default {
|
||||
const { mutate, loading, error, onDone } = useMutation(
|
||||
() => showRegister.value ? USER_REGISTER : USER_LOGIN,
|
||||
() => ({
|
||||
variables: showRegister.value ? {
|
||||
input: {
|
||||
...formData,
|
||||
variables: showRegister.value
|
||||
? {
|
||||
input: {
|
||||
...formData,
|
||||
},
|
||||
}
|
||||
: {
|
||||
email: formData.email,
|
||||
password: formData.password,
|
||||
},
|
||||
} : {
|
||||
email: formData.email,
|
||||
password: formData.password,
|
||||
},
|
||||
})
|
||||
}),
|
||||
)
|
||||
|
||||
onDone(async result => {
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
schema.graphql
|
||||
dist/
|
||||
@@ -1,31 +0,0 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
|
||||
env: {
|
||||
node: true,
|
||||
},
|
||||
|
||||
'extends': [
|
||||
'plugin:vue/recommended',
|
||||
'@vue/standard',
|
||||
],
|
||||
|
||||
rules: {
|
||||
'graphql/template-strings': [
|
||||
'error',
|
||||
{
|
||||
env: 'literal',
|
||||
projectName: 'app',
|
||||
},
|
||||
],
|
||||
'comma-dangle': ['error', 'always-multiline'],
|
||||
},
|
||||
|
||||
parserOptions: {
|
||||
parser: 'babel-eslint',
|
||||
},
|
||||
|
||||
plugins: [
|
||||
'graphql',
|
||||
],
|
||||
}
|
||||
@@ -7,8 +7,8 @@ const messages = [
|
||||
userId: '__bot',
|
||||
channelId: 'general',
|
||||
content: 'Welcome to the chat!',
|
||||
dateAdded: Date.now()
|
||||
}
|
||||
dateAdded: Date.now(),
|
||||
},
|
||||
]
|
||||
|
||||
function publishChange ({ type, message }, context) {
|
||||
|
||||
@@ -6,8 +6,8 @@ const users = [
|
||||
email: 'bot@bot.com',
|
||||
password: 'bot',
|
||||
nickname: 'The Bot',
|
||||
tokens: []
|
||||
}
|
||||
tokens: [],
|
||||
},
|
||||
]
|
||||
|
||||
exports.register = (input, context) => {
|
||||
@@ -24,7 +24,7 @@ exports.register = (input, context) => {
|
||||
nickname: input.nickname,
|
||||
tokens: [],
|
||||
})
|
||||
|
||||
|
||||
resolve(true)
|
||||
}, 100)
|
||||
})
|
||||
@@ -32,7 +32,7 @@ exports.register = (input, context) => {
|
||||
|
||||
exports.login = ({ email, password }, context) => {
|
||||
const user = users.find(
|
||||
u => u.email === email && u.password === password
|
||||
u => u.email === email && u.password === password,
|
||||
)
|
||||
if (!user) throw new Error('User not found')
|
||||
const token = {
|
||||
|
||||
@@ -45,7 +45,7 @@ module.exports = {
|
||||
messageChanged: {
|
||||
subscribe: withFilter(
|
||||
(parent, args, { pubsub }) => pubsub.asyncIterator(triggers.MESSAGE_CHANGED),
|
||||
(payload, vars) => payload.messageChanged.message.channelId === vars.channelId
|
||||
(payload, vars) => payload.messageChanged.message.channelId === vars.channelId,
|
||||
),
|
||||
},
|
||||
},
|
||||
|
||||
@@ -5,10 +5,9 @@
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"lint": "vue-cli-service lint",
|
||||
"apollo:dev": "vue-cli-service apollo:dev",
|
||||
"apollo:start": "vue-cli-service apollo:start --port 4042",
|
||||
"test": "yarn run lint --no-fix && yarn run test:e2e",
|
||||
"test": "yarn run test:e2e",
|
||||
"test:e2e": "start-server-and-test apollo:start http://localhost:4042/.well-known/apollo/server-health test:e2e:client",
|
||||
"test:e2e:client": "vue-cli-service test:e2e --mode production --headless",
|
||||
"test:e2e:dev": "start-server-and-test apollo:dev http://localhost:4042/.well-known/apollo/server-health test:e2e:dev:client",
|
||||
@@ -28,13 +27,7 @@
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-babel": "^4.0.4",
|
||||
"@vue/cli-plugin-e2e-cypress": "^4.0.4",
|
||||
"@vue/cli-plugin-eslint": "^4.0.4",
|
||||
"@vue/cli-service": "^4.0.4",
|
||||
"@vue/eslint-config-standard": "^4.0.0",
|
||||
"babel-eslint": "^10.0.3",
|
||||
"eslint": "^4.19.1",
|
||||
"eslint-plugin-graphql": "^3.1.0",
|
||||
"eslint-plugin-vue": "^5.2.3",
|
||||
"graphql-tag": "^2.5.0",
|
||||
"start-server-and-test": "^1.10.6",
|
||||
"stylus": "^0.54.5",
|
||||
|
||||
@@ -52,7 +52,7 @@ export default {
|
||||
},
|
||||
|
||||
async scrollToBottom (force = false) {
|
||||
let el = this.$refs.body
|
||||
const el = this.$refs.body
|
||||
|
||||
// No body element yet
|
||||
if (!el) {
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
schema.graphql
|
||||
dist/
|
||||
@@ -1,33 +0,0 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
|
||||
env: {
|
||||
node: true
|
||||
},
|
||||
|
||||
'extends': [
|
||||
'plugin:vue/essential',
|
||||
'@vue/standard'
|
||||
],
|
||||
|
||||
rules: {
|
||||
'no-console': 'off',
|
||||
'no-debugger': 'off',
|
||||
// 'graphql/template-strings': [
|
||||
// 'error',
|
||||
// {
|
||||
// env: 'literal',
|
||||
// projectName: 'app',
|
||||
// schemaJsonFilepath: 'node_modules/.temp/graphql/schema.json'
|
||||
// }
|
||||
// ]
|
||||
},
|
||||
|
||||
parserOptions: {
|
||||
parser: 'babel-eslint'
|
||||
},
|
||||
|
||||
plugins: [
|
||||
'graphql'
|
||||
]
|
||||
}
|
||||
@@ -20,10 +20,5 @@ yarn build
|
||||
yarn test:e2e
|
||||
```
|
||||
|
||||
### Lints and fixes files
|
||||
```
|
||||
yarn lint
|
||||
```
|
||||
|
||||
### Customize configuration
|
||||
See [Configuration Reference](https://cli.vuejs.org/config/).
|
||||
|
||||
@@ -8,7 +8,7 @@ import { processUpload } from './utils/upload'
|
||||
export default ({ req, connection }) => {
|
||||
return {
|
||||
db,
|
||||
processUpload
|
||||
processUpload,
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,13 +5,13 @@ export default {
|
||||
JSON: GraphQLJSON,
|
||||
|
||||
Counter: {
|
||||
countStr: counter => `Current count: ${counter.count}`
|
||||
countStr: counter => `Current count: ${counter.count}`,
|
||||
},
|
||||
|
||||
Query: {
|
||||
hello: (root, { name }) => `Hello ${name || 'World'}!`,
|
||||
messages: (root, args, { db }) => db.get('messages').value(),
|
||||
uploads: (root, args, { db }) => db.get('uploads').value()
|
||||
uploads: (root, args, { db }) => db.get('uploads').value(),
|
||||
|
||||
},
|
||||
|
||||
@@ -24,7 +24,7 @@ export default {
|
||||
addMessage: (root, { input }, { pubsub, db }) => {
|
||||
const message = {
|
||||
id: shortid.generate(),
|
||||
text: input.text
|
||||
text: input.text,
|
||||
}
|
||||
|
||||
db
|
||||
@@ -39,13 +39,13 @@ export default {
|
||||
},
|
||||
|
||||
singleUpload: (root, { file }, { processUpload }) => processUpload(file),
|
||||
multipleUpload: (root, { files }, { processUpload }) => Promise.all(files.map(processUpload))
|
||||
multipleUpload: (root, { files }, { processUpload }) => Promise.all(files.map(processUpload)),
|
||||
|
||||
},
|
||||
|
||||
Subscription: {
|
||||
mySub: {
|
||||
subscribe: (parent, args, { pubsub }) => pubsub.asyncIterator('hey')
|
||||
subscribe: (parent, args, { pubsub }) => pubsub.asyncIterator('hey'),
|
||||
},
|
||||
counter: {
|
||||
subscribe: (parent, args, { pubsub }) => {
|
||||
@@ -55,16 +55,16 @@ export default {
|
||||
channel,
|
||||
{
|
||||
// eslint-disable-next-line no-plusplus
|
||||
counter: { count: count++ }
|
||||
}
|
||||
counter: { count: count++ },
|
||||
},
|
||||
), 2000)
|
||||
return pubsub.asyncIterator(channel)
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
messageAdded: {
|
||||
subscribe: (parent, args, { pubsub }) => pubsub.asyncIterator('messages')
|
||||
}
|
||||
subscribe: (parent, args, { pubsub }) => pubsub.asyncIterator('messages'),
|
||||
},
|
||||
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -25,5 +25,5 @@ db.defaults({
|
||||
text: 'Message 3',
|
||||
},
|
||||
],
|
||||
uploads: []
|
||||
uploads: [],
|
||||
}).write()
|
||||
|
||||
@@ -19,7 +19,7 @@ const storeUpload = async ({ stream, filename }) => {
|
||||
stream
|
||||
.pipe(createWriteStream(path))
|
||||
.on('finish', () => resolve({ id, path: urlPath }))
|
||||
.on('error', reject)
|
||||
.on('error', reject),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -4,20 +4,20 @@ const path = require('path')
|
||||
const { loadEnv } = require('vue-cli-plugin-apollo/utils/load-env')
|
||||
const env = loadEnv([
|
||||
path.resolve(__dirname, '.env'),
|
||||
path.resolve(__dirname, '.env.local')
|
||||
path.resolve(__dirname, '.env.local'),
|
||||
])
|
||||
|
||||
module.exports = {
|
||||
client: {
|
||||
service: env.VUE_APP_APOLLO_ENGINE_SERVICE,
|
||||
includes: ['src/**/*.{js,jsx,ts,tsx,vue,gql}']
|
||||
includes: ['src/**/*.{js,jsx,ts,tsx,vue,gql}'],
|
||||
},
|
||||
service: {
|
||||
name: env.VUE_APP_APOLLO_ENGINE_SERVICE,
|
||||
localSchemaFile: path.resolve(__dirname, './node_modules/.temp/graphql/schema.json')
|
||||
localSchemaFile: path.resolve(__dirname, './node_modules/.temp/graphql/schema.json'),
|
||||
},
|
||||
engine: {
|
||||
endpoint: process.env.APOLLO_ENGINE_API_ENDPOINT,
|
||||
apiKey: env.VUE_APP_APOLLO_ENGINE_KEY
|
||||
}
|
||||
apiKey: env.VUE_APP_APOLLO_ENGINE_KEY,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module.exports = {
|
||||
presets: [
|
||||
'@vue/cli-plugin-babel/preset'
|
||||
]
|
||||
'@vue/cli-plugin-babel/preset',
|
||||
],
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"lint": "vue-cli-service lint",
|
||||
"apollo": "vue-cli-service apollo:dev --generate-schema",
|
||||
"apollo:schema:generate": "vue-cli-service apollo:schema:generate",
|
||||
"apollo:schema:publish": "vue-cli-service apollo:schema:publish",
|
||||
@@ -13,7 +12,7 @@
|
||||
"ssr:build": "vue-cli-service ssr:build",
|
||||
"ssr:serve": "vue-cli-service ssr:serve",
|
||||
"ssr:start": "cross-env NODE_ENV=production vue-cli-service ssr:serve --mode production",
|
||||
"test": "yarn apollo:schema:generate && yarn run lint --no-fix && yarn run test:e2e",
|
||||
"test": "yarn apollo:schema:generate && yarn run test:e2e",
|
||||
"test:e2e": "start-server-and-test apollo:start http://localhost:4042/.well-known/apollo/server-health test:e2e:run",
|
||||
"test:e2e:run": "start-server-and-test ssr:serve http://localhost:8000 test:e2e:client",
|
||||
"test:e2e:client": "vue-cli-service test:e2e --mode production --headless --url http://localhost:8000",
|
||||
@@ -38,14 +37,8 @@
|
||||
"@akryum/vue-cli-plugin-ssr": "^0.6.0",
|
||||
"@vue/cli-plugin-babel": "^4.0.0",
|
||||
"@vue/cli-plugin-e2e-cypress": "^4.0.0",
|
||||
"@vue/cli-plugin-eslint": "^4.0.0",
|
||||
"@vue/cli-plugin-router": "^4.0.0",
|
||||
"@vue/cli-service": "^4.0.0",
|
||||
"@vue/eslint-config-standard": "^4.0.0",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"eslint": "^5.16.0",
|
||||
"eslint-plugin-graphql": "^2.1.1",
|
||||
"eslint-plugin-vue": "^5.0.0",
|
||||
"graphql-tag": "^2.9.0",
|
||||
"start-server-and-test": "^1.10.6",
|
||||
"vue-cli-plugin-apollo": "^0.21.3",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module.exports = {
|
||||
plugins: {
|
||||
autoprefixer: {}
|
||||
}
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,13 +1,24 @@
|
||||
<template>
|
||||
<div id="app">
|
||||
<div id="nav">
|
||||
<router-link to="/">Home</router-link> |
|
||||
<router-link to="/apollo">Apollo</router-link> |
|
||||
<router-link to="/about">About</router-link>
|
||||
<router-link to="/">
|
||||
Home
|
||||
</router-link> |
|
||||
<router-link to="/apollo">
|
||||
Apollo
|
||||
</router-link> |
|
||||
<router-link to="/about">
|
||||
About
|
||||
</router-link>
|
||||
</div>
|
||||
<router-view/>
|
||||
<router-view />
|
||||
|
||||
<div v-if="apolloState" class="apollo-state">{{ apolloState }}</div>
|
||||
<div
|
||||
v-if="apolloState"
|
||||
class="apollo-state"
|
||||
>
|
||||
{{ apolloState }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -23,9 +34,9 @@ export default {
|
||||
})
|
||||
|
||||
return {
|
||||
apolloState
|
||||
apolloState,
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -14,16 +14,16 @@ export default {
|
||||
return {
|
||||
messages: [
|
||||
...previousResult.messages,
|
||||
subscriptionData.data.messageAdded
|
||||
]
|
||||
subscriptionData.data.messageAdded,
|
||||
],
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
return {
|
||||
messages
|
||||
messages,
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
<template>
|
||||
<div v-if="loading">Loading...</div>
|
||||
<div v-else class="messages">
|
||||
<div v-if="loading">
|
||||
Loading...
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
class="messages"
|
||||
>
|
||||
{{ messages.length }} messages
|
||||
</div>
|
||||
</template>
|
||||
@@ -15,8 +20,8 @@ export default {
|
||||
const messages = useResult(result, [])
|
||||
return {
|
||||
messages,
|
||||
loading: useQueryLoading()
|
||||
loading: useQueryLoading(),
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
<template>
|
||||
<div class="hello">
|
||||
<input v-model="name" class="input">
|
||||
<div class="hello">{{ hello }}</div>
|
||||
<input
|
||||
v-model="name"
|
||||
class="input"
|
||||
>
|
||||
<div class="hello">
|
||||
{{ hello }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -14,13 +19,13 @@ export default {
|
||||
setup () {
|
||||
const name = ref('')
|
||||
const { result } = useQuery(HELLO_WORLD, () => ({
|
||||
name: name.value
|
||||
name: name.value,
|
||||
}))
|
||||
const hello = useResult(result)
|
||||
return {
|
||||
name,
|
||||
hello
|
||||
hello,
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -5,17 +5,17 @@ import { createApp } from './main'
|
||||
|
||||
createApp({
|
||||
async beforeApp ({
|
||||
router
|
||||
router,
|
||||
}) {
|
||||
await loadAsyncComponents({ router })
|
||||
},
|
||||
|
||||
afterApp ({
|
||||
app,
|
||||
router
|
||||
router,
|
||||
}) {
|
||||
router.onReady(() => {
|
||||
app.$mount('#app')
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -14,7 +14,7 @@ export default context => {
|
||||
const {
|
||||
app,
|
||||
router,
|
||||
apolloClient
|
||||
apolloClient,
|
||||
} = await createApp()
|
||||
|
||||
router.push(prepareUrlForRouting(context.url))
|
||||
@@ -23,7 +23,7 @@ export default context => {
|
||||
context.rendered = () => {
|
||||
// Same for Apollo client cache
|
||||
context.apolloState = ApolloSSR.getStates({
|
||||
defaultClient: apolloClient
|
||||
defaultClient: apolloClient,
|
||||
})
|
||||
}
|
||||
resolve(app)
|
||||
|
||||
@@ -11,17 +11,17 @@ Vue.config.productionTip = false
|
||||
|
||||
export async function createApp ({
|
||||
beforeApp = () => {},
|
||||
afterApp = () => {}
|
||||
afterApp = () => {},
|
||||
} = {}) {
|
||||
const router = createRouter()
|
||||
|
||||
const apolloClient = createClient({
|
||||
ssr: process.server
|
||||
ssr: process.server,
|
||||
})
|
||||
|
||||
await beforeApp({
|
||||
router,
|
||||
apolloClient
|
||||
apolloClient,
|
||||
})
|
||||
|
||||
const app = new Vue({
|
||||
@@ -31,13 +31,13 @@ export async function createApp ({
|
||||
provide(DefaultApolloClient, apolloClient)
|
||||
},
|
||||
|
||||
render: h => h(App)
|
||||
render: h => h(App),
|
||||
})
|
||||
|
||||
const result = {
|
||||
app,
|
||||
router,
|
||||
apolloClient
|
||||
apolloClient,
|
||||
}
|
||||
|
||||
await afterApp(result)
|
||||
|
||||
@@ -9,22 +9,22 @@ export function createRouter () {
|
||||
{
|
||||
path: '/',
|
||||
name: 'home',
|
||||
component: Home
|
||||
component: Home,
|
||||
},
|
||||
{
|
||||
path: '/apollo',
|
||||
name: 'apollo',
|
||||
component: () => import(/* webpackChunkName: "apollo" */ '../components/ApolloExample.vue')
|
||||
component: () => import(/* webpackChunkName: "apollo" */ '../components/ApolloExample.vue'),
|
||||
},
|
||||
{
|
||||
path: '/apollo-loading',
|
||||
name: 'apollo-loading',
|
||||
component: () => import(/* webpackChunkName: "apollo-loading" */ '../components/ApolloLoading.vue')
|
||||
component: () => import(/* webpackChunkName: "apollo-loading" */ '../components/ApolloLoading.vue'),
|
||||
},
|
||||
{
|
||||
path: '/hello',
|
||||
name: 'hello',
|
||||
component: () => import(/* webpackChunkName: "hello" */ '../components/HelloWorld.vue')
|
||||
component: () => import(/* webpackChunkName: "hello" */ '../components/HelloWorld.vue'),
|
||||
},
|
||||
{
|
||||
path: '/about',
|
||||
@@ -32,14 +32,14 @@ export function createRouter () {
|
||||
// route level code-splitting
|
||||
// this generates a separate chunk (about.[hash].js) for this route
|
||||
// which is lazy-loaded when the route is visited.
|
||||
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
|
||||
}
|
||||
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue'),
|
||||
},
|
||||
]
|
||||
|
||||
const router = new VueRouter({
|
||||
mode: 'history',
|
||||
base: process.env.BASE_URL,
|
||||
routes
|
||||
routes,
|
||||
})
|
||||
|
||||
return router
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<template>
|
||||
<div class="home">
|
||||
<img alt="Vue logo" src="../assets/logo.png">
|
||||
<img
|
||||
alt="Vue logo"
|
||||
src="../assets/logo.png"
|
||||
>
|
||||
|
||||
<div>{{ meow }}</div>
|
||||
<div>{{ kui.hi }}</div>
|
||||
@@ -13,17 +16,17 @@
|
||||
import { ref, reactive } from '@vue/composition-api'
|
||||
import Vue from 'vue'
|
||||
export default {
|
||||
name: 'home',
|
||||
name: 'Home',
|
||||
|
||||
setup (props, { isServer }) {
|
||||
const meow = ref('waf')
|
||||
meow.value = 'meow'
|
||||
const kui = reactive({
|
||||
hi: 'waf'
|
||||
hi: 'waf',
|
||||
})
|
||||
kui.hi = 'kui'
|
||||
const meuh = Vue.observable({
|
||||
hi: 'waf'
|
||||
hi: 'waf',
|
||||
})
|
||||
meuh.hi = 'meuh'
|
||||
console.log(kui)
|
||||
@@ -31,8 +34,8 @@ export default {
|
||||
meow,
|
||||
kui,
|
||||
meuh,
|
||||
isServer
|
||||
isServer,
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -26,7 +26,7 @@ const defaultOptions = {
|
||||
// You need to pass a `wsEndpoint` for this to work
|
||||
websocketsOnly: false,
|
||||
// Is being rendered on the server?
|
||||
ssr: false
|
||||
ssr: false,
|
||||
|
||||
// Override default apollo link
|
||||
// note: don't override httpLink here, specify httpLink options in the
|
||||
@@ -51,7 +51,7 @@ export function createClient (options = {}) {
|
||||
// Create apollo client
|
||||
const { apolloClient, wsClient } = createApolloClient({
|
||||
...defaultOptions,
|
||||
...options
|
||||
...options,
|
||||
})
|
||||
apolloClient.wsClient = wsClient
|
||||
return apolloClient
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
module.exports = {
|
||||
plugins: [
|
||||
'cypress'
|
||||
'cypress',
|
||||
],
|
||||
env: {
|
||||
mocha: true,
|
||||
'cypress/globals': true
|
||||
'cypress/globals': true,
|
||||
},
|
||||
rules: {
|
||||
strict: 'off'
|
||||
}
|
||||
strict: 'off',
|
||||
},
|
||||
}
|
||||
|
||||
@@ -19,6 +19,6 @@ module.exports = (on, config) => {
|
||||
integrationFolder: 'tests/e2e/specs',
|
||||
screenshotsFolder: 'tests/e2e/screenshots',
|
||||
videosFolder: 'tests/e2e/videos',
|
||||
supportFile: 'tests/e2e/support/index.js'
|
||||
supportFile: 'tests/e2e/support/index.js',
|
||||
})
|
||||
}
|
||||
|
||||
@@ -3,19 +3,19 @@ module.exports = {
|
||||
pluginOptions: {
|
||||
apollo: {
|
||||
enableMocks: false,
|
||||
enableEngine: false
|
||||
}
|
||||
enableEngine: false,
|
||||
},
|
||||
},
|
||||
|
||||
chainWebpack (config) {
|
||||
config.resolve.symlinks(false)
|
||||
config.externals([
|
||||
'utf-8-validate',
|
||||
'bufferutil'
|
||||
'bufferutil',
|
||||
])
|
||||
config.module.noParse([
|
||||
/iconv-loader/
|
||||
/iconv-loader/,
|
||||
])
|
||||
config.resolve.alias.set('vue-demi', '@vue/composition-api')
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
schema.graphql
|
||||
dist/
|
||||
@@ -1,33 +0,0 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
|
||||
env: {
|
||||
node: true
|
||||
},
|
||||
|
||||
'extends': [
|
||||
'plugin:vue/essential',
|
||||
'@vue/standard'
|
||||
],
|
||||
|
||||
rules: {
|
||||
'no-console': 'off',
|
||||
'no-debugger': 'off',
|
||||
// 'graphql/template-strings': [
|
||||
// 'error',
|
||||
// {
|
||||
// env: 'literal',
|
||||
// projectName: 'app',
|
||||
// schemaJsonFilepath: 'node_modules/.temp/graphql/schema.json'
|
||||
// }
|
||||
// ]
|
||||
},
|
||||
|
||||
parserOptions: {
|
||||
parser: 'babel-eslint'
|
||||
},
|
||||
|
||||
plugins: [
|
||||
'graphql'
|
||||
]
|
||||
}
|
||||
@@ -20,10 +20,5 @@ yarn build
|
||||
yarn test:e2e
|
||||
```
|
||||
|
||||
### Lints and fixes files
|
||||
```
|
||||
yarn lint
|
||||
```
|
||||
|
||||
### Customize configuration
|
||||
See [Configuration Reference](https://cli.vuejs.org/config/).
|
||||
|
||||
@@ -8,7 +8,7 @@ import { processUpload } from './utils/upload'
|
||||
export default ({ req, connection }) => {
|
||||
return {
|
||||
db,
|
||||
processUpload
|
||||
processUpload,
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,13 +5,13 @@ export default {
|
||||
JSON: GraphQLJSON,
|
||||
|
||||
Counter: {
|
||||
countStr: counter => `Current count: ${counter.count}`
|
||||
countStr: counter => `Current count: ${counter.count}`,
|
||||
},
|
||||
|
||||
Query: {
|
||||
hello: (root, { name }) => `Hello ${name || 'World'}!`,
|
||||
messages: (root, args, { db }) => db.get('messages').value(),
|
||||
uploads: (root, args, { db }) => db.get('uploads').value()
|
||||
uploads: (root, args, { db }) => db.get('uploads').value(),
|
||||
|
||||
},
|
||||
|
||||
@@ -24,7 +24,7 @@ export default {
|
||||
addMessage: (root, { input }, { pubsub, db }) => {
|
||||
const message = {
|
||||
id: shortid.generate(),
|
||||
text: input.text
|
||||
text: input.text,
|
||||
}
|
||||
|
||||
db
|
||||
@@ -39,13 +39,13 @@ export default {
|
||||
},
|
||||
|
||||
singleUpload: (root, { file }, { processUpload }) => processUpload(file),
|
||||
multipleUpload: (root, { files }, { processUpload }) => Promise.all(files.map(processUpload))
|
||||
multipleUpload: (root, { files }, { processUpload }) => Promise.all(files.map(processUpload)),
|
||||
|
||||
},
|
||||
|
||||
Subscription: {
|
||||
mySub: {
|
||||
subscribe: (parent, args, { pubsub }) => pubsub.asyncIterator('hey')
|
||||
subscribe: (parent, args, { pubsub }) => pubsub.asyncIterator('hey'),
|
||||
},
|
||||
counter: {
|
||||
subscribe: (parent, args, { pubsub }) => {
|
||||
@@ -55,16 +55,16 @@ export default {
|
||||
channel,
|
||||
{
|
||||
// eslint-disable-next-line no-plusplus
|
||||
counter: { count: count++ }
|
||||
}
|
||||
counter: { count: count++ },
|
||||
},
|
||||
), 2000)
|
||||
return pubsub.asyncIterator(channel)
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
messageAdded: {
|
||||
subscribe: (parent, args, { pubsub }) => pubsub.asyncIterator('messages')
|
||||
}
|
||||
subscribe: (parent, args, { pubsub }) => pubsub.asyncIterator('messages'),
|
||||
},
|
||||
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -25,5 +25,5 @@ db.defaults({
|
||||
text: 'Message 3',
|
||||
},
|
||||
],
|
||||
uploads: []
|
||||
uploads: [],
|
||||
}).write()
|
||||
|
||||
@@ -19,7 +19,7 @@ const storeUpload = async ({ stream, filename }) => {
|
||||
stream
|
||||
.pipe(createWriteStream(path))
|
||||
.on('finish', () => resolve({ id, path: urlPath }))
|
||||
.on('error', reject)
|
||||
.on('error', reject),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -4,20 +4,20 @@ const path = require('path')
|
||||
const { loadEnv } = require('vue-cli-plugin-apollo/utils/load-env')
|
||||
const env = loadEnv([
|
||||
path.resolve(__dirname, '.env'),
|
||||
path.resolve(__dirname, '.env.local')
|
||||
path.resolve(__dirname, '.env.local'),
|
||||
])
|
||||
|
||||
module.exports = {
|
||||
client: {
|
||||
service: env.VUE_APP_APOLLO_ENGINE_SERVICE,
|
||||
includes: ['src/**/*.{js,jsx,ts,tsx,vue,gql}']
|
||||
includes: ['src/**/*.{js,jsx,ts,tsx,vue,gql}'],
|
||||
},
|
||||
service: {
|
||||
name: env.VUE_APP_APOLLO_ENGINE_SERVICE,
|
||||
localSchemaFile: path.resolve(__dirname, './node_modules/.temp/graphql/schema.json')
|
||||
localSchemaFile: path.resolve(__dirname, './node_modules/.temp/graphql/schema.json'),
|
||||
},
|
||||
engine: {
|
||||
endpoint: process.env.APOLLO_ENGINE_API_ENDPOINT,
|
||||
apiKey: env.VUE_APP_APOLLO_ENGINE_KEY
|
||||
}
|
||||
apiKey: env.VUE_APP_APOLLO_ENGINE_KEY,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module.exports = {
|
||||
presets: [
|
||||
'@vue/cli-plugin-babel/preset'
|
||||
]
|
||||
'@vue/cli-plugin-babel/preset',
|
||||
],
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"lint": "vue-cli-service lint",
|
||||
"apollo": "vue-cli-service apollo:dev --generate-schema",
|
||||
"apollo:schema:generate": "vue-cli-service apollo:schema:generate",
|
||||
"apollo:schema:publish": "vue-cli-service apollo:schema:publish",
|
||||
@@ -13,7 +12,7 @@
|
||||
"ssr:build": "vue-cli-service ssr:build",
|
||||
"ssr:serve": "vue-cli-service ssr:serve",
|
||||
"ssr:start": "cross-env NODE_ENV=production vue-cli-service ssr:serve --mode production",
|
||||
"test": "yarn apollo:schema:generate && yarn run lint --no-fix && yarn run test:e2e",
|
||||
"test": "yarn apollo:schema:generate && yarn run test:e2e",
|
||||
"test:e2e": "start-server-and-test apollo:start http://localhost:4042/.well-known/apollo/server-health test:e2e:run",
|
||||
"test:e2e:run": "start-server-and-test ssr:serve http://localhost:8000 test:e2e:client",
|
||||
"test:e2e:client": "vue-cli-service test:e2e --mode production --headless --url http://localhost:8000",
|
||||
@@ -38,14 +37,9 @@
|
||||
"@akryum/vue-cli-plugin-ssr": "^0.6.0",
|
||||
"@vue/cli-plugin-babel": "^4.0.0",
|
||||
"@vue/cli-plugin-e2e-cypress": "^4.0.0",
|
||||
"@vue/cli-plugin-eslint": "^4.0.0",
|
||||
"@vue/cli-plugin-router": "^4.0.0",
|
||||
"@vue/cli-service": "^4.0.0",
|
||||
"@vue/eslint-config-standard": "^4.0.0",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"eslint": "^5.16.0",
|
||||
"eslint-plugin-graphql": "^2.1.1",
|
||||
"eslint-plugin-vue": "^5.0.0",
|
||||
"graphql-tag": "^2.9.0",
|
||||
"start-server-and-test": "^1.10.6",
|
||||
"vue-cli-plugin-apollo": "^0.21.3",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module.exports = {
|
||||
plugins: {
|
||||
autoprefixer: {}
|
||||
}
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,13 +1,24 @@
|
||||
<template>
|
||||
<div id="app">
|
||||
<div id="nav">
|
||||
<router-link to="/">Home</router-link> |
|
||||
<router-link to="/apollo">Apollo</router-link> |
|
||||
<router-link to="/about">About</router-link>
|
||||
<router-link to="/">
|
||||
Home
|
||||
</router-link> |
|
||||
<router-link to="/apollo">
|
||||
Apollo
|
||||
</router-link> |
|
||||
<router-link to="/about">
|
||||
About
|
||||
</router-link>
|
||||
</div>
|
||||
<router-view/>
|
||||
<router-view />
|
||||
|
||||
<div v-if="apolloState" class="apollo-state">{{ apolloState }}</div>
|
||||
<div
|
||||
v-if="apolloState"
|
||||
class="apollo-state"
|
||||
>
|
||||
{{ apolloState }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -15,13 +26,13 @@
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
apolloState: null
|
||||
apolloState: null,
|
||||
}
|
||||
},
|
||||
|
||||
mounted () {
|
||||
this.apolloState = JSON.stringify(window.__APOLLO_STATE__)
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -31,11 +31,11 @@ export default {
|
||||
return {
|
||||
messages: [
|
||||
...previousResult.messages,
|
||||
subscriptionData.data.messageAdded
|
||||
]
|
||||
subscriptionData.data.messageAdded,
|
||||
],
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
<template>
|
||||
<div v-if="$apollo.queries.messages.loading">Loading...</div>
|
||||
<div v-else class="messages">
|
||||
<div v-if="$apollo.queries.messages.loading">
|
||||
Loading...
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
class="messages"
|
||||
>
|
||||
{{ messages.length }} messages
|
||||
</div>
|
||||
</template>
|
||||
@@ -10,7 +15,7 @@ import MESSAGES from '../graphql/Messages.gql'
|
||||
|
||||
export default {
|
||||
apollo: {
|
||||
messages: MESSAGES
|
||||
}
|
||||
messages: MESSAGES,
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
<template>
|
||||
<div class="hello">
|
||||
<input v-model="name" class="input">
|
||||
<div class="hello">{{ hello }}</div>
|
||||
<input
|
||||
v-model="name"
|
||||
class="input"
|
||||
>
|
||||
<div class="hello">
|
||||
{{ hello }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -11,7 +16,7 @@ import HELLO_WORLD from '../graphql/HelloWorld.gql'
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
name: ''
|
||||
name: '',
|
||||
}
|
||||
},
|
||||
|
||||
@@ -20,10 +25,10 @@ export default {
|
||||
query: HELLO_WORLD,
|
||||
variables () {
|
||||
return {
|
||||
name: this.name
|
||||
name: this.name,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -5,17 +5,17 @@ import { createApp } from './main'
|
||||
|
||||
createApp({
|
||||
async beforeApp ({
|
||||
router
|
||||
router,
|
||||
}) {
|
||||
await loadAsyncComponents({ router })
|
||||
},
|
||||
|
||||
afterApp ({
|
||||
app,
|
||||
router
|
||||
router,
|
||||
}) {
|
||||
router.onReady(() => {
|
||||
app.$mount('#app')
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -14,7 +14,7 @@ export default context => {
|
||||
const {
|
||||
app,
|
||||
router,
|
||||
apolloProvider
|
||||
apolloProvider,
|
||||
} = await createApp()
|
||||
|
||||
router.push(prepareUrlForRouting(context.url))
|
||||
|
||||
@@ -7,31 +7,31 @@ Vue.config.productionTip = false
|
||||
|
||||
export async function createApp ({
|
||||
beforeApp = () => {},
|
||||
afterApp = () => {}
|
||||
afterApp = () => {},
|
||||
} = {}) {
|
||||
const router = createRouter()
|
||||
|
||||
const apolloProvider = createProvider({
|
||||
ssr: process.server
|
||||
ssr: process.server,
|
||||
})
|
||||
|
||||
await beforeApp({
|
||||
router,
|
||||
|
||||
apolloProvider
|
||||
apolloProvider,
|
||||
})
|
||||
|
||||
const app = new Vue({
|
||||
router,
|
||||
apolloProvider,
|
||||
render: h => h(App)
|
||||
render: h => h(App),
|
||||
})
|
||||
|
||||
const result = {
|
||||
app,
|
||||
router,
|
||||
|
||||
apolloProvider
|
||||
apolloProvider,
|
||||
}
|
||||
|
||||
await afterApp(result)
|
||||
|
||||
@@ -9,22 +9,22 @@ export function createRouter () {
|
||||
{
|
||||
path: '/',
|
||||
name: 'home',
|
||||
component: Home
|
||||
component: Home,
|
||||
},
|
||||
{
|
||||
path: '/apollo',
|
||||
name: 'apollo',
|
||||
component: () => import(/* webpackChunkName: "apollo" */ '../components/ApolloExample.vue')
|
||||
component: () => import(/* webpackChunkName: "apollo" */ '../components/ApolloExample.vue'),
|
||||
},
|
||||
{
|
||||
path: '/apollo-loading',
|
||||
name: 'apollo-loading',
|
||||
component: () => import(/* webpackChunkName: "apollo-loading" */ '../components/ApolloLoading.vue')
|
||||
component: () => import(/* webpackChunkName: "apollo-loading" */ '../components/ApolloLoading.vue'),
|
||||
},
|
||||
{
|
||||
path: '/hello',
|
||||
name: 'hello',
|
||||
component: () => import(/* webpackChunkName: "hello" */ '../components/HelloWorld.vue')
|
||||
component: () => import(/* webpackChunkName: "hello" */ '../components/HelloWorld.vue'),
|
||||
},
|
||||
{
|
||||
path: '/about',
|
||||
@@ -32,14 +32,14 @@ export function createRouter () {
|
||||
// route level code-splitting
|
||||
// this generates a separate chunk (about.[hash].js) for this route
|
||||
// which is lazy-loaded when the route is visited.
|
||||
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
|
||||
}
|
||||
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue'),
|
||||
},
|
||||
]
|
||||
|
||||
const router = new VueRouter({
|
||||
mode: 'history',
|
||||
base: process.env.BASE_URL,
|
||||
routes
|
||||
routes,
|
||||
})
|
||||
|
||||
return router
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
<template>
|
||||
<div class="home">
|
||||
<img alt="Vue logo" src="../assets/logo.png">
|
||||
<img
|
||||
alt="Vue logo"
|
||||
src="../assets/logo.png"
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'home'
|
||||
name: 'Home',
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -32,7 +32,7 @@ const defaultOptions = {
|
||||
// You need to pass a `wsEndpoint` for this to work
|
||||
websocketsOnly: false,
|
||||
// Is being rendered on the server?
|
||||
ssr: false
|
||||
ssr: false,
|
||||
|
||||
// Override default apollo link
|
||||
// note: don't override httpLink here, specify httpLink options in the
|
||||
@@ -57,7 +57,7 @@ export function createProvider (options = {}) {
|
||||
// Create apollo client
|
||||
const { apolloClient, wsClient } = createApolloClient({
|
||||
...defaultOptions,
|
||||
...options
|
||||
...options,
|
||||
})
|
||||
apolloClient.wsClient = wsClient
|
||||
|
||||
@@ -67,12 +67,12 @@ export function createProvider (options = {}) {
|
||||
defaultOptions: {
|
||||
$query: {
|
||||
// fetchPolicy: 'cache-and-network',
|
||||
}
|
||||
},
|
||||
},
|
||||
errorHandler (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('%cError', 'background: red; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;', error.message)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
return apolloProvider
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
module.exports = {
|
||||
plugins: [
|
||||
'cypress'
|
||||
'cypress',
|
||||
],
|
||||
env: {
|
||||
mocha: true,
|
||||
'cypress/globals': true
|
||||
'cypress/globals': true,
|
||||
},
|
||||
rules: {
|
||||
strict: 'off'
|
||||
}
|
||||
strict: 'off',
|
||||
},
|
||||
}
|
||||
|
||||
@@ -19,6 +19,6 @@ module.exports = (on, config) => {
|
||||
integrationFolder: 'tests/e2e/specs',
|
||||
screenshotsFolder: 'tests/e2e/screenshots',
|
||||
videosFolder: 'tests/e2e/videos',
|
||||
supportFile: 'tests/e2e/support/index.js'
|
||||
supportFile: 'tests/e2e/support/index.js',
|
||||
})
|
||||
}
|
||||
|
||||
@@ -3,18 +3,18 @@ module.exports = {
|
||||
pluginOptions: {
|
||||
apollo: {
|
||||
enableMocks: false,
|
||||
enableEngine: false
|
||||
}
|
||||
enableEngine: false,
|
||||
},
|
||||
},
|
||||
|
||||
chainWebpack (config) {
|
||||
config.resolve.symlinks(false)
|
||||
config.externals([
|
||||
'utf-8-validate',
|
||||
'bufferutil'
|
||||
'bufferutil',
|
||||
])
|
||||
config.module.noParse([
|
||||
/iconv-loader/
|
||||
/iconv-loader/,
|
||||
])
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
node_modules/
|
||||
dist/
|
||||
schema.graphql
|
||||
@@ -1,30 +0,0 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
parser: 'babel-eslint',
|
||||
parserOptions: {
|
||||
sourceType: 'module'
|
||||
},
|
||||
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
|
||||
extends: 'standard',
|
||||
// required to lint *.vue files
|
||||
/* plugins: [
|
||||
'html'
|
||||
], */
|
||||
env: {
|
||||
browser: true,
|
||||
},
|
||||
// add your custom rules here
|
||||
'rules': {
|
||||
// allow paren-less arrow functions
|
||||
'arrow-parens': 0,
|
||||
// allow async-await
|
||||
'generator-star-spacing': 0,
|
||||
// allow debugger during development
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
|
||||
// trailing comma
|
||||
'comma-dangle': ['error', 'always-multiline'],
|
||||
// beware of returning assignement
|
||||
'no-return-assign': 'off',
|
||||
'no-extend-native': 'warn',
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
module.exports = {
|
||||
'presets': [
|
||||
[require('@babel/preset-env'), { 'modules': false }],
|
||||
presets: [
|
||||
[require('@babel/preset-env'), { modules: false }],
|
||||
],
|
||||
'plugins': [
|
||||
plugins: [
|
||||
require('@babel/plugin-proposal-class-properties'),
|
||||
[require('@babel/plugin-transform-for-of'), { assumeArray: true }],
|
||||
],
|
||||
|
||||
@@ -10,10 +10,8 @@
|
||||
"build:browser": "rollup --config build/rollup.config.browser.js",
|
||||
"build:es": "rollup --config build/rollup.config.es.js",
|
||||
"build:umd": "rollup --config build/rollup.config.umd.js",
|
||||
"prepublishOnly": "yarn test && yarn build",
|
||||
"dev": "nodemon --exec 'yarn build:es && yarn build:umd' --watch src --watch lib",
|
||||
"test": "yarn build && yarn lint",
|
||||
"lint": "eslint --ext .js {src,ssr,lib,build}/**/*.js"
|
||||
"prepublishOnly": "yarn build",
|
||||
"dev": "nodemon --exec 'yarn build:es && yarn build:umd' --watch src --watch lib"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -46,14 +44,7 @@
|
||||
"@types/graphql": "^14.0.1",
|
||||
"@vue/test-utils": "^1.0.0-beta.25",
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"cross-env": "^6.0.0",
|
||||
"eslint": "^6.3.0",
|
||||
"eslint-config-standard": "^12.0.0",
|
||||
"eslint-plugin-import": "^2.8.0",
|
||||
"eslint-plugin-node": "^10.0.0",
|
||||
"eslint-plugin-promise": "^4.0.1",
|
||||
"eslint-plugin-standard": "^4.0.0",
|
||||
"graphql": "^14.0.2",
|
||||
"jest": "^24.8.0",
|
||||
"nodemon": "^1.18.4",
|
||||
@@ -64,7 +55,6 @@
|
||||
"rollup-plugin-node-resolve": "^5.2.0",
|
||||
"rollup-plugin-replace": "^2.0.0",
|
||||
"rollup-plugin-uglify": "^6.0.0",
|
||||
"typescript": "^3.1.3",
|
||||
"uglify-es": "^3.1.6",
|
||||
"vue": "^2.5.16",
|
||||
"vue-property-decorator": "^8.2.2"
|
||||
|
||||
@@ -8,11 +8,11 @@ export function install (Vue, options) {
|
||||
if (install.installed) return
|
||||
install.installed = true
|
||||
|
||||
Vue.component('apollo-query', CApolloQuery)
|
||||
Vue.component('ApolloQuery', CApolloQuery)
|
||||
Vue.component('apollo-subscribe-to-more', CApolloSubscribeToMore)
|
||||
Vue.component('ApolloQuery', CApolloQuery)
|
||||
Vue.component('ApolloSubscribeToMore', CApolloSubscribeToMore)
|
||||
Vue.component('apollo-mutation', CApolloMutation)
|
||||
Vue.component('ApolloSubscribeToMore', CApolloSubscribeToMore)
|
||||
Vue.component('ApolloMutation', CApolloMutation)
|
||||
Vue.component('ApolloMutation', CApolloMutation)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
node_modules/
|
||||
dist/
|
||||
@@ -1,17 +0,0 @@
|
||||
const { join } = require('path')
|
||||
|
||||
module.exports = {
|
||||
root: true,
|
||||
extends: 'standard-with-typescript',
|
||||
parserOptions: {
|
||||
project: join(__dirname, './tsconfig.lint.json'),
|
||||
},
|
||||
rules: {
|
||||
// trailing comma
|
||||
'comma-dangle': ['error', 'always-multiline'],
|
||||
'@typescript-eslint/strict-boolean-expressions': 'off',
|
||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||
'@typescript-eslint/promise-function-async': 'off',
|
||||
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'off',
|
||||
},
|
||||
}
|
||||
@@ -31,8 +31,7 @@
|
||||
"dev": "tsc -d -w --sourceMap",
|
||||
"build": "rimraf dist && node esbuild.mjs && tsc -d --emitDeclarationOnly",
|
||||
"prepublishOnly": "yarn test && yarn build",
|
||||
"test": "yarn lint && yarn test:types",
|
||||
"lint": "eslint . --ext .js,.ts",
|
||||
"test": "yarn test:types",
|
||||
"test:types": "tsc -p tests/types/"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -48,15 +47,6 @@
|
||||
"devDependencies": {
|
||||
"@apollo/client": "^3.0.0",
|
||||
"@types/throttle-debounce": "^2.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "^4.4.1",
|
||||
"@typescript-eslint/parser": "^4.4.1",
|
||||
"@vue/composition-api": "^1.0.0-beta.16",
|
||||
"eslint": "^7.11.0",
|
||||
"eslint-config-standard-with-typescript": "^19.0.1",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-promise": "^4.2.1",
|
||||
"eslint-plugin-standard": "^4.0.1",
|
||||
"typescript": "^4.0.3"
|
||||
"@vue/composition-api": "^1.0.0-beta.16"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ export interface UseMutationReturn<TResult, TVariables> {
|
||||
onError: (fn: (param: Error) => void) => {
|
||||
off: () => void
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function useMutation<
|
||||
TResult = any,
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
isRef,
|
||||
computed,
|
||||
watch,
|
||||
// @ts-expect-error
|
||||
// @ts-expect-error No implemented on Vue 3 yet, see https://github.com/vuejs/vue-next/pull/3070
|
||||
onServerPrefetch,
|
||||
getCurrentInstance,
|
||||
onBeforeUnmount,
|
||||
@@ -46,7 +46,7 @@ export interface UseQueryOptions<
|
||||
|
||||
interface SubscribeToMoreItem {
|
||||
options: any
|
||||
unsubscribeFns: Function[]
|
||||
unsubscribeFns: (() => void)[]
|
||||
}
|
||||
|
||||
// Parameters
|
||||
@@ -137,7 +137,7 @@ export function useQueryImpl<
|
||||
document: DocumentParameter<TResult, TVariables>,
|
||||
variables?: VariablesParameter<TVariables>,
|
||||
options: OptionsParameter<TResult, TVariables> = {},
|
||||
lazy: boolean = false,
|
||||
lazy = false,
|
||||
): UseQueryReturn<TResult, TVariables> {
|
||||
// Is on server?
|
||||
const vm = getCurrentInstance() as CurrentInstance | null
|
||||
@@ -166,8 +166,8 @@ export function useQueryImpl<
|
||||
const networkStatus = ref<number>()
|
||||
|
||||
// SSR
|
||||
let firstResolve: Function | undefined
|
||||
let firstReject: Function | undefined
|
||||
let firstResolve: (() => void) | undefined
|
||||
let firstReject: ((error: Error) => void) | undefined
|
||||
onServerPrefetch?.(() => {
|
||||
if (!isEnabled.value || (isServer && currentOptions.value?.prefetch === false)) return
|
||||
|
||||
@@ -215,9 +215,11 @@ export function useQueryImpl<
|
||||
query: currentDocument,
|
||||
variables: currentVariables,
|
||||
...currentOptions.value,
|
||||
...isServer ? {
|
||||
fetchPolicy: 'network-only',
|
||||
} : {},
|
||||
...isServer
|
||||
? {
|
||||
fetchPolicy: 'network-only',
|
||||
}
|
||||
: {},
|
||||
})
|
||||
|
||||
startQuerySubscription()
|
||||
@@ -345,7 +347,7 @@ export function useQueryImpl<
|
||||
})
|
||||
}
|
||||
|
||||
let debouncedRestart: Function
|
||||
let debouncedRestart: typeof baseRestart
|
||||
let isRestartDebounceSetup = false
|
||||
function updateRestartFn () {
|
||||
// On server, will be called before currentOptions is initialized
|
||||
|
||||
@@ -196,7 +196,7 @@ export function useSubscription <
|
||||
})
|
||||
}
|
||||
|
||||
let debouncedRestart: Function
|
||||
let debouncedRestart: typeof baseRestart
|
||||
function updateRestartFn () {
|
||||
if (currentOptions.value?.throttle) {
|
||||
debouncedRestart = throttle(currentOptions.value.throttle, baseRestart)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Ref, isRef, reactive, computed } from 'vue-demi'
|
||||
import { ReactiveFunction } from './ReactiveFunction'
|
||||
|
||||
export function paramToReactive<T extends object> (param: T | Ref<T> | ReactiveFunction<T>): T | Ref<T> {
|
||||
export function paramToReactive<T extends Record<string, unknown>> (param: T | Ref<T> | ReactiveFunction<T>): T | Ref<T> {
|
||||
if (isRef(param)) {
|
||||
return param
|
||||
} else if (typeof param === 'function') {
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
node_modules/
|
||||
dist/
|
||||
schema.graphql
|
||||
@@ -1,30 +0,0 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
parser: 'babel-eslint',
|
||||
parserOptions: {
|
||||
sourceType: 'module'
|
||||
},
|
||||
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
|
||||
extends: 'standard',
|
||||
// required to lint *.vue files
|
||||
/* plugins: [
|
||||
'html'
|
||||
], */
|
||||
env: {
|
||||
browser: true,
|
||||
},
|
||||
// add your custom rules here
|
||||
'rules': {
|
||||
// allow paren-less arrow functions
|
||||
'arrow-parens': 0,
|
||||
// allow async-await
|
||||
'generator-star-spacing': 0,
|
||||
// allow debugger during development
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
|
||||
// trailing comma
|
||||
'comma-dangle': ['error', 'always-multiline'],
|
||||
// beware of returning assignement
|
||||
'no-return-assign': 'off',
|
||||
'no-extend-native': 'warn',
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
module.exports = {
|
||||
'presets': [
|
||||
[require('@babel/preset-env'), { 'modules': false }],
|
||||
presets: [
|
||||
[require('@babel/preset-env'), { modules: false }],
|
||||
],
|
||||
'plugins': [
|
||||
plugins: [
|
||||
require('@babel/plugin-proposal-class-properties'),
|
||||
[require('@babel/plugin-transform-for-of'), { assumeArray: true }],
|
||||
],
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
"build:umd": "rollup --config build/rollup.config.umd.js",
|
||||
"prepublishOnly": "yarn test && yarn build",
|
||||
"dev": "nodemon --exec 'yarn build:es && yarn build:umd' --watch src --watch lib",
|
||||
"test": "yarn build && yarn lint && yarn test:types && yarn run test:unit",
|
||||
"lint": "eslint --ext .js {src,ssr,lib,build}/**/*.js",
|
||||
"test": "yarn build && yarn test:types && yarn run test:unit",
|
||||
"test:types": "tsc -p types/test",
|
||||
"test:unit": "yarn run jest"
|
||||
},
|
||||
@@ -53,14 +52,7 @@
|
||||
"@types/graphql": "^14.0.1",
|
||||
"@vue/test-utils": "^1.0.0-beta.25",
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"cross-env": "^6.0.0",
|
||||
"eslint": "^6.3.0",
|
||||
"eslint-config-standard": "^12.0.0",
|
||||
"eslint-plugin-import": "^2.8.0",
|
||||
"eslint-plugin-node": "^10.0.0",
|
||||
"eslint-plugin-promise": "^4.0.1",
|
||||
"eslint-plugin-standard": "^4.0.0",
|
||||
"graphql": "^14.0.2",
|
||||
"graphql-tag": "^2.5.0",
|
||||
"jest": "^24.8.0",
|
||||
@@ -72,7 +64,6 @@
|
||||
"rollup-plugin-node-resolve": "^5.2.0",
|
||||
"rollup-plugin-replace": "^2.0.0",
|
||||
"rollup-plugin-uglify": "^6.0.0",
|
||||
"typescript": "^3.1.3",
|
||||
"uglify-es": "^3.1.6",
|
||||
"vue": "^2.5.16",
|
||||
"vue-property-decorator": "^8.2.2"
|
||||
|
||||
@@ -52,7 +52,7 @@ export class DollarApollo {
|
||||
const observable = this.getClient(options).watchQuery(options)
|
||||
const _subscribe = observable.subscribe.bind(observable)
|
||||
observable.subscribe = (options) => {
|
||||
let sub = _subscribe(options)
|
||||
const sub = _subscribe(options)
|
||||
this._apolloSubscriptions.push(sub)
|
||||
return sub
|
||||
}
|
||||
@@ -68,7 +68,7 @@ export class DollarApollo {
|
||||
const observable = this.getClient(options).subscribe(options)
|
||||
const _subscribe = observable.subscribe.bind(observable)
|
||||
observable.subscribe = (options) => {
|
||||
let sub = _subscribe(options)
|
||||
const sub = _subscribe(options)
|
||||
this._apolloSubscriptions.push(sub)
|
||||
return sub
|
||||
}
|
||||
@@ -168,13 +168,13 @@ export class DollarApollo {
|
||||
}
|
||||
|
||||
set skipAllQueries (value) {
|
||||
for (let key in this.queries) {
|
||||
for (const key in this.queries) {
|
||||
this.queries[key].skip = value
|
||||
}
|
||||
}
|
||||
|
||||
set skipAllSubscriptions (value) {
|
||||
for (let key in this.subscriptions) {
|
||||
for (const key in this.subscriptions) {
|
||||
this.subscriptions[key].skip = value
|
||||
}
|
||||
}
|
||||
@@ -188,10 +188,10 @@ export class DollarApollo {
|
||||
for (const unwatch of this._watchers) {
|
||||
unwatch()
|
||||
}
|
||||
for (let key in this.queries) {
|
||||
for (const key in this.queries) {
|
||||
this.queries[key].destroy()
|
||||
}
|
||||
for (let key in this.subscriptions) {
|
||||
for (const key in this.subscriptions) {
|
||||
this.subscriptions[key].destroy()
|
||||
}
|
||||
this._apolloSubscriptions.forEach((sub) => {
|
||||
|
||||
@@ -29,12 +29,12 @@ function initProvider () {
|
||||
function proxyData () {
|
||||
this.$_apolloInitData = {}
|
||||
|
||||
let apollo = this.$options.apollo
|
||||
const apollo = this.$options.apollo
|
||||
if (apollo) {
|
||||
// watchQuery
|
||||
for (let key in apollo) {
|
||||
for (const key in apollo) {
|
||||
if (key.charAt(0) !== '$') {
|
||||
let options = apollo[key]
|
||||
const options = apollo[key]
|
||||
// Property proxy
|
||||
if (!options.manual && !hasProperty(this.$options.props, key) && !hasProperty(this.$options.computed, key) && !hasProperty(this.$options.methods, key)) {
|
||||
Object.defineProperty(this, key, {
|
||||
@@ -87,7 +87,7 @@ function launch () {
|
||||
})
|
||||
|
||||
// watchQuery
|
||||
for (let key in apollo) {
|
||||
for (const key in apollo) {
|
||||
if (key.charAt(0) !== '$') {
|
||||
let options = apollo[key]
|
||||
const smart = this.$apollo.addSmartQuery(key, options)
|
||||
@@ -105,7 +105,7 @@ function launch () {
|
||||
}
|
||||
|
||||
if (apollo.$subscribe) {
|
||||
for (let key in apollo.$subscribe) {
|
||||
for (const key in apollo.$subscribe) {
|
||||
this.$apollo.addSmartSubscription(key, apollo.$subscribe[key])
|
||||
}
|
||||
}
|
||||
@@ -131,14 +131,16 @@ function destroy () {
|
||||
|
||||
export function installMixin (Vue, vueVersion) {
|
||||
Vue.mixin({
|
||||
...vueVersion === '1' ? {
|
||||
init: initProvider,
|
||||
} : {},
|
||||
...vueVersion === '1'
|
||||
? {
|
||||
init: initProvider,
|
||||
}
|
||||
: {},
|
||||
|
||||
...vueVersion === '2' ? {
|
||||
data () {
|
||||
return {
|
||||
'$apolloData': {
|
||||
$apolloData: {
|
||||
queries: {},
|
||||
loading: 0,
|
||||
data: this.$_apolloInitData,
|
||||
|
||||
@@ -153,7 +153,7 @@ export default class SmartApollo {
|
||||
for (const handler of handlers) {
|
||||
if (handler) {
|
||||
catched = true
|
||||
let result = handler.apply(this.vm, args)
|
||||
const result = handler.apply(this.vm, args)
|
||||
if (typeof result !== 'undefined' && !result) {
|
||||
break
|
||||
}
|
||||
@@ -179,7 +179,7 @@ export default class SmartApollo {
|
||||
|
||||
if (error.graphQLErrors && error.graphQLErrors.length !== 0) {
|
||||
console.error(`GraphQL execution errors for ${this.type} '${this.key}'`)
|
||||
for (let e of error.graphQLErrors) {
|
||||
for (const e of error.graphQLErrors) {
|
||||
console.error(e)
|
||||
}
|
||||
} else if (error.networkError) {
|
||||
|
||||
@@ -29,7 +29,7 @@ export default class SmartQuery extends SmartApollo {
|
||||
}
|
||||
|
||||
if (!options.manual) {
|
||||
this.hasDataField = this.vm.$data.hasOwnProperty(key)
|
||||
this.hasDataField = Object.prototype.hasOwnProperty.call(this.vm.$data, key)
|
||||
if (this.hasDataField) {
|
||||
Object.defineProperty(this.vm.$data.$apolloData.data, key, {
|
||||
get: () => this.vm.$data[key],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module.exports = {
|
||||
env: {
|
||||
jest: true
|
||||
}
|
||||
}
|
||||
jest: true,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@ describe('ssr states', () => {
|
||||
}
|
||||
|
||||
const defaultClient = buildClient({
|
||||
'foo': '<alert>hiya!</alert>',
|
||||
foo: '<alert>hiya!</alert>',
|
||||
})
|
||||
|
||||
const otherClient = buildClient({
|
||||
'foo': 'bar',
|
||||
foo: 'bar',
|
||||
})
|
||||
|
||||
const clients = {
|
||||
|
||||
+7
-6
@@ -5,7 +5,7 @@ import { ApolloClient } from '@apollo/client/core'
|
||||
import {
|
||||
VueApolloComponentOptions,
|
||||
WatchLoading,
|
||||
ErrorHandler
|
||||
ErrorHandler,
|
||||
} from './options'
|
||||
|
||||
export type VueApolloComponent<V extends Vue = Vue> = VueApolloComponentOptions<V> | typeof Vue | AsyncComponent
|
||||
@@ -13,13 +13,14 @@ export type VueApolloComponent<V extends Vue = Vue> = VueApolloComponentOptions<
|
||||
export class ApolloProvider<TCacheShape=any> {
|
||||
provide: (key?: string) => this
|
||||
constructor (options: {
|
||||
defaultClient: ApolloClient<TCacheShape>,
|
||||
defaultOptions?: VueApolloComponentOptions<Vue>,
|
||||
clients?: { [key: string]: ApolloClient<TCacheShape> },
|
||||
watchLoading?: WatchLoading,
|
||||
errorHandler?: ErrorHandler,
|
||||
defaultClient: ApolloClient<TCacheShape>
|
||||
defaultOptions?: VueApolloComponentOptions<Vue>
|
||||
clients?: { [key: string]: ApolloClient<TCacheShape> }
|
||||
watchLoading?: WatchLoading
|
||||
errorHandler?: ErrorHandler
|
||||
prefetch?: boolean
|
||||
})
|
||||
|
||||
clients: { [key: string]: ApolloClient<TCacheShape> }
|
||||
defaultClient: ApolloClient<TCacheShape>
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user