apollographql / apollo-tooling

✏️ Apollo CLI for client tooling (Mostly replaced by Rover)
https://apollographql.com
MIT License
3.04k stars 469 forks source link

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'name' of undefined #2168

Open masihjahangiri opened 3 years ago

masihjahangiri commented 3 years ago

My apollo.config.js is:

module.exports = {
  client: {
    service: {
      name: 'pelas-graphQL',
      url: 'http://api.pelas.co/graphql',
    },
  },
};

I get this error in my vscode log.

(node:10372) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'name' of undefined
    at Object.visitor (c:\Users\Masih-Jahangiri\.vscode\extensions\apollographql.vscode-apollo-1.17.0\node_modules\apollo-language-server\lib\errors\validation.js:102:96)
    at Object.enter (c:\Users\Masih-Jahangiri\.vscode\extensions\apollographql.vscode-apollo-1.17.0\node_modules\graphql\language\visitor.js:323:29)
    at Object.enter (c:\Users\Masih-Jahangiri\.vscode\extensions\apollographql.vscode-apollo-1.17.0\node_modules\graphql\utilities\TypeInfo.js:370:25)
    at Object.visit (c:\Users\Masih-Jahangiri\.vscode\extensions\apollographql.vscode-apollo-1.17.0\node_modules\graphql\language\visitor.js:243:26)
    at Object.getValidationErrors (c:\Users\Masih-Jahangiri\.vscode\extensions\apollographql.vscode-apollo-1.17.0\node_modules\apollo-language-server\lib\errors\validation.js:26:15)
    at Object.collectExecutableDefinitionDiagnositics (c:\Users\Masih-Jahangiri\.vscode\extensions\apollographql.vscode-apollo-1.17.0\node_modules\apollo-language-server\lib\diagnostics.js:14:38)
    at GraphQLClientProject.validate (c:\Users\Masih-Jahangiri\.vscode\extensions\apollographql.vscode-apollo-1.17.0\node_modules\apollo-language-server\lib\project\client.js:182:65)
    at c:\Users\Masih-Jahangiri\.vscode\extensions\apollographql.vscode-apollo-1.17.0\node_modules\apollo-language-server\lib\workspace.js:58:46
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
(node:10372) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:10372) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Versions Apollo GraphQL vscode plugin: v1.17.0

VScode: Version: 1.51.1 (user setup) Commit: e5a624b788d92b8d34d1392e4c4d9789406efe8f Date: 2020-11-10T23:34:32.027Z Electron: 9.3.3 Chrome: 83.0.4103.122 Node.js: 12.14.1 V8: 8.3.110.13-electron.0 OS: Windows_NT x64 10.0.18363

masihjahangiri commented 3 years ago

@JakeDawkins @abernix Do you have any idea? It's a simple and weird issue.

masihjahangiri commented 3 years ago

I solved my problem temporary, I added excludes field to remove the local schema. My local schema doesn't have any problem and it doesn't conflict with the remote server schema. apollo.config.js is:

module.exports = {
  client: {
    excludes: ['./src/client/localState/localSchema.gql'],
    service: {
      name: 'pelas',
      url: 'http://api.pelas.co/graphql',
    },
  },
};

localSchema.gql:

extend type Query {
  localState: QueryLocalState!
}

extend type Mutation {
  localStateUpdateIsLoggedIn(isLoggedIn: Boolean!): Boolean!
}

type QueryLocalStateUser {
  id: ID!
  isLoggedIn: Boolean!
}

type QueryLocalState {
  id: ID!
  user: QueryLocalStateUser!
}

The remote server schema: http://api.pelas.co/graphql