当我启动和关闭服务器时,所有查询和变异均不起作用

时间:2019-06-06 10:39:21

标签: javascript node.js reactjs graphql apollo

当我关闭服务器并启动时,所有查询和变异均不起作用。
但是有可能在我去操场上并运行任何查询或变异后。

我非常努力地找出原因。 我只是放弃了,每次我开始 我去操场上并运行查询。

clinet包。Json

    "apollo": "^2.6.2",
    "apollo-boost": "^0.1.23",
    "apollo-cache-inmemory": "^1.5.1",

server package.json

        "bcryptjs": "^2.4.3",
        "cors": "^2.8.5",
        "dotenv": "^6.2.0",
        "graphql-tools": "^4.0.4",
        "graphql-yoga": "^1.17.1",
        "helmet": "^3.15.0",
        "jsonwebtoken": "^8.4.0",
        "lodash": "^4.17.11",
        "mailgun-js": "^0.22.0",
        "merge-graphql-schemas": "^1.5.8",
        "mongodb": "^3.1.13",
        "mongoose": "^5.4.12",
        "morgan": "^1.9.1",
        "reflect-metadata": "^0.1.13",
        "request-promise": "^4.2.2",
        "typegoose": "^5.6.0"

apollo客户端


import ApolloClient, {InMemoryCache} from "apollo-boost";
import dotenv from "dotenv";
import uri from "./uri";
import resolvers from "./resolvers";
import {toast} from "react-toastify";

dotenv.config({
  path: "../.env"
});

const client = new ApolloClient({
  clientState: {
    defaults: {
      auth: {
        __typename: "Auth",
        isLoggedIn: Boolean(localStorage.getItem("jwt")),
        lastSelectedHouse: {
          __typename: "House",
          value: localStorage.getItem("selectId"),
          label: localStorage.getItem("selectHouseLabel")
        }
      }
    },
    resolvers
  },
  request: async operation => {
    operation.setContext({
      headers: {
        "X-JWT": localStorage.getItem("jwt") || "",
        "HP-Key": localStorage.getItem("hpk") || ""
      }
    });
  },
  uri,
  credentials: "omit",
  cache: new InMemoryCache({
    addTypename: true
  }),
  onError: ({graphQLErrors, networkError}) => {
    if (graphQLErrors)
      graphQLErrors.map(({message, locations, path}) =>
        // 이건 DEV 용 메세지임 showError가 기타 에러 처리할것임
        console.log(
          `[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`
        )
      );
    if (networkError) {
      console.log(`[Network error]: ${networkError}`);
      // toast.warn("네트워크 문제발생");
    }
  }
});

export default client;

完整服务器package.json


{
    "name": "server_dev",
    "version": "1.0.0",
    "description": "Janda Reservation Module for Development.",
    "main": "index.js",
    "author": "ksc2601@gmail.com",
    "license": "MIT",
    "devDependencies": {
        "@types/bcryptjs": "^2.4.2",
        "@types/bson": "^4.0.0",
        "@types/graphql": "^14.0.5",
        "@types/helmet": "^0.0.42",
        "@types/jsonwebtoken": "^8.3.0",
        "@types/lodash": "^4.14.123",
        "@types/mailgun-js": "^0.16.3",
        "@types/mongodb": "^3.1.19",
        "@types/mongoose": "^5.3.17",
        "@types/morgan": "^1.7.35",
        "@types/node": "^10.12.19",
        "@types/request-promise": "^4.1.42",
        "babel-runtime": "^6.26.0",
        "copy": "^0.3.2",
        "gql-merge": "^0.0.6",
        "graphql-to-typescript": "^0.1.2",
        "mocha": "^6.0.2",
        "nodemon": "^1.18.9",
        "prettier": "^1.16.4",
        "prettier-tslint": "^0.4.2",
        "ts-node": "^8.0.2",
        "tslint": "^5.12.1",
        "tslint-config-prettier": "^1.18.0",
        "tslint-plugin-prettier": "^2.0.1",
        "typescript": "^3.3.3333"
    },
    "scripts": {
        "predev": "yarn run types",
        "dev": "cd src && nodemon --exec ts-node index.ts -e ts,graphql",
        "pretypes": "gql-merge --out-file ./src/schema.graphql ./src/api/**/*.graphql",
        "types": "graphql-to-typescript ./src/schema.graphql ./src/types/graph.d.ts",
        "build": "tsc",
        "postbuild": "yarn copy src/api/**/*.graphql dist/api",
        "start": "cd dist && node index.js"
    },
    "dependencies": {
        "bcryptjs": "^2.4.3",
        "cors": "^2.8.5",
        "dotenv": "^6.2.0",
        "graphql-tools": "^4.0.4",
        "graphql-yoga": "^1.17.1",
        "helmet": "^3.15.0",
        "jsonwebtoken": "^8.4.0",
        "lodash": "^4.17.11",
        "mailgun-js": "^0.22.0",
        "merge-graphql-schemas": "^1.5.8",
        "mongodb": "^3.1.13",
        "mongoose": "^5.4.12",
        "morgan": "^1.9.1",
        "reflect-metadata": "^0.1.13",
        "request-promise": "^4.2.2",
        "typegoose": "^5.6.0"
    }
}

完整客户端package.json

{
  "name": "client_dev",
  "version": "1.0.0",
  "description": "Janda Reservation Module for Development(client)",
  "main": "index.jsx",
  "author": "BKY",
  "license": "MIT",
  "private": true,
  "dependencies": {
    "@babel/core": "7.1.0",
    "@babel/plugin-syntax-json-strings": "^7.2.0",
    "@svgr/webpack": "2.4.1",
    "@types/dotenv": "^6.1.1",
    "@types/lodash": "^4.14.123",
    "@types/moment-timezone": "^0.5.12",
    "@types/react-addons-css-transition-group": "^15.0.5",
    "@types/react-calendar-timeline": "^0.16.1",
    "@types/react-sticky": "^6.0.3",
    "@types/react-sticky-el": "^1.0.2",
    "@types/react-table": "^6.8.3",
    "@types/react-tabs": "^2.3.1",
    "@types/react-tooltip": "^3.9.2",
    "@types/react-window-size": "^1.2.0",
    "apollo": "^2.6.2",
    "apollo-boost": "^0.1.23",
    "apollo-cache-inmemory": "^1.5.1",
    "axios": "^0.18.0",
    "babel-cli": "^6.26.0",
    "babel-core": "7.0.0-bridge.0",
    "babel-eslint": "9.0.0",
    "babel-jest": "23.6.0",
    "babel-loader": "8.0.4",
    "babel-plugin-named-asset-import": "^0.2.3",
    "babel-polyfill": "^6.26.0",
    "babel-preset-react-app": "^6.1.0",
    "bfj": "6.1.1",
    "browser-detect": "^0.2.28",
    "case-sensitive-paths-webpack-plugin": "2.1.2",
    "chalk": "2.4.1",
    "classnames": "^2.2.6",
    "css-loader": "1.0.0",
    "dotenv": "6.0.0",
    "dotenv-expand": "4.2.0",
    "download": "^7.1.0",
    "download-file": "^0.1.5",
    "eslint": "^5.16.0",
    "eslint-config-react-app": "^3.0.5",
    "eslint-loader": "2.1.1",
    "eslint-plugin-flowtype": "2.50.1",
    "eslint-plugin-import": "2.14.0",
    "eslint-plugin-jsx-a11y": "6.1.2",
    "eslint-plugin-react": "7.11.1",
    "faker": "^4.1.0",
    "file-loader": "2.0.0",
    "fork-ts-checker-webpack-plugin-alt": "0.4.14",
    "fs": "^0.0.1-security",
    "fs-extra": "7.0.0",
    "github-markdown-css": "^3.0.1",
    "global": "^4.3.2",
    "google-maps-react": "^2.0.2",
    "graphql-tag": "^2.10.0",
    "html-webpack-plugin": "4.0.0-alpha.2",
    "iamporter": "^1.4.2",
    "identity-obj-proxy": "3.0.0",
    "interactjs": "^1.3.4",
    "jest": "23.6.0",
    "jest-pnp-resolver": "1.0.1",
    "jest-resolve": "23.6.0",
    "jquery": "^3.3.1",
    "json2xls": "^0.1.2",
    "lodash": "^4.17.11",
    "lodash.debounce": "^4.0.8",
    "markdown-to-jsx": "^6.9.1",
    "mini-css-extract-plugin": "0.4.3",
    "moment": "^2.24.0",
    "moment-timezone": "^0.5.25",
    "node-sass": "^4.11.0",
    "optimize-css-assets-webpack-plugin": "5.0.1",
    "outdated-browser-rework": "^2.8.0",
    "pnp-webpack-plugin": "1.1.0",
    "postcss-flexbugs-fixes": "4.1.0",
    "postcss-loader": "3.0.0",
    "postcss-preset-env": "6.0.6",
    "postcss-safe-parser": "4.0.1",
    "prop-types": "^15.6.2",
    "randomcolor": "^0.5.4",
    "react": "^16.7.0",
    "react-addons-css-transition-group": "^15.6.2",
    "react-apollo": "^2.3.3",
    "react-app-polyfill": "^0.1.3",
    "react-calendar-timeline": "^0.25.1",
    "react-color": "^2.17.0",
    "react-compound-timer": "^1.0.13",
    "react-day-picker": "^7.2.4",
    "react-dev-utils": "^6.1.1",
    "react-dom": "^16.7.0",
    "react-drag-list": "^1.1.0",
    "react-draggable-list": "^4.0.2",
    "react-favicon": "^0.0.14",
    "react-helmet": "^5.2.0",
    "react-modal": "^3.8.1",
    "react-naver-map": "^0.0.23",
    "react-paginate": "^6.3.0",
    "react-router": "^5.0.0",
    "react-router-dom": "^4.3.1",
    "react-scripts-ts": "^3.1.0",
    "react-search-field": "^1.0.0",
    "react-select": "^2.3.0",
    "react-slick": "^0.23.2",
    "react-sticky": "^6.0.3",
    "react-sticky-el": "^1.0.20",
    "react-table": "^6.10.0",
    "react-tabs": "^3.0.0",
    "react-toastify": "^4.5.2",
    "react-tooltip": "^3.9.2",
    "react-window-size": "^1.2.2",
    "resolve": "1.8.1",
    "sass-loader": "7.1.0",
    "style-loader": "0.23.0",
    "terser-webpack-plugin": "1.1.0",
    "tui-editor": "^1.4.0",
    "url-loader": "1.1.1",
    "webpack": "4.19.1",
    "webpack-dev-server": "3.1.9",
    "webpack-manifest-plugin": "2.0.4",
    "whatwg-fetch": "^3.0.0",
    "workbox-webpack-plugin": "3.6.3"
  },
  "scripts": {
    "start": "node scripts/start.js",
    "build": "node scripts/build.js",
    "test": "node scripts/test.js",
    "precodegen": "apollo schema:download --endpoint=http://localhost:4000/graphql",
    "codegen": "apollo codegen:generate src/types/api.d.ts --queries=src/queries.ts --localSchemaFile=schema.json --target=typescript --outputFlat"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "eslintIgnore": [
    "naverMap.js",
    "**/*.js"
  ],
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "devDependencies": {
    "@types/classnames": "^2.2.7",
    "@types/faker": "^4.1.5",
    "@types/googlemaps": "^3.30.19",
    "@types/graphql": "^14.0.7",
    "@types/jquery": "^3.3.29",
    "@types/moment": "^2.13.0",
    "@types/randomcolor": "^0.5.1",
    "@types/react": "^16.8.6",
    "@types/react-color": "^3.0.0",
    "@types/react-dom": "^16.8.2",
    "@types/react-helmet": "^5.0.8",
    "@types/react-modal": "^3.8.1",
    "@types/react-paginate": "^6.2.1",
    "@types/react-router-dom": "^4.3.1",
    "@types/react-select": "^2.0.15",
    "@typescript-eslint/eslint-plugin": "^1.6.0",
    "@typescript-eslint/parser": "^1.6.0",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-plugin-graphql": "^3.0.1",
    "eslint-plugin-prettier": "^3.0.1",
    "eslint-plugin-react-hooks": "^1.0.1",
    "stylelint": "^9.10.1",
    "stylelint-config-prettier": "^4.0.0",
    "stylelint-config-recommended-scss": "^3.2.0",
    "tslint": "^5.14.0",
    "typescript": "^3.3.4000"
  },
  "jest": {
    "collectCoverageFrom": [
      "src/**/*.{js,jsx,ts,tsx}",
      "!src/**/*.d.ts"
    ],
    "resolver": "jest-pnp-resolver",
    "setupFiles": [
      "react-app-polyfill/jsdom"
    ],
    "testMatch": [
      "<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
      "<rootDir>/src/**/?(*.)(spec|test).{js,jsx,ts,tsx}"
    ],
    "testEnvironment": "jsdom",
    "testURL": "http://localhost",
    "transform": {
      "^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
      "^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
      "^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
    },
    "transformIgnorePatterns": [
      "[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
      "^.+\\.module\\.(css|sass|scss)$"
    ],
    "moduleNameMapper": {
      "^react-native$": "react-native-web",
      "^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
    },
    "moduleFileExtensions": [
      "web.js",
      "js",
      "web.ts",
      "ts",
      "web.tsx",
      "tsx",
      "json",
      "web.jsx",
      "jsx",
      "node"
    ]
  },
  "babel": {
    "presets": [
      "react-app"
    ]
  }
}

0 个答案:

没有答案