Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'schemaPath' of undefined #2345

Closed
tomitrescak opened this issue Jul 20, 2018 · 36 comments
Closed

TypeError: Cannot read property 'schemaPath' of undefined #2345

tomitrescak opened this issue Jul 20, 2018 · 36 comments
Labels
lsp-server graphql-language-service-server

Comments

@tomitrescak
Copy link

Hi,

I cannot make this run on Windows ;(
I am receiving this error:

(node:6500) 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.
[Error - 14:13:40] Request textDocument/hover failed.
  Message: Request textDocument/hover failed with message: Cannot read property 'projectName' of undefined
  Code: -32603 

This is my .graphqlconfig.yml

projects:
  app:
    schemaPath: "src/data/yoga/schema.graphql"
    includes: ["src/**/*.graphql"]
    extensions:
      endpoints:
        default: "http://localhost:4000"
      codegen:
        - generator: prisma-binding
          language: typescript
          output: 
            binding: src/data/generated/api.ts
  prisma:
    schemaPath: "src/data/generated/prisma.graphql"
    includes: ["src/**/*.graphql"]
    extensions:
      prisma: src/data/prisma/prisma.yml
      codegen:
        - generator: prisma-binding
          language: typescript
          output: 
            binding: src/data/generated/prisma.ts

All Works well on MAC with this setup

@ntziolis
Copy link

ntziolis commented Aug 4, 2018

Seeing the same issue

@divyenduz
Copy link
Contributor

@ntziolis : Are you also running windows? I will pick this up shortly.

@ntziolis
Copy link

ntziolis commented Aug 6, 2018

Yes I am. That said, I'm pretty sure think this was related to an old graphql version. Since I updated the graphql version locally as well as globally the error has dissapeared and im getting linting and auto completion for .graphql files but not yet in gql tags. See the gql tag issue as I provided a repository for reproduction.

@tomitrescak What version of graphql or graphql-cli do you have installed globally/locally?

@tomitrescak
Copy link
Author

tomitrescak commented Aug 10, 2018

@ntziolis no love for me ;(
I have 2.16.5 for graphql-cli and latest graphql - 0.13.2

@tomitrescak
Copy link
Author

@ntziolis @divyenduz do you maybe have a repo that I can download and test, whether the problem is not in my configuration? My error window is full of following:

(node:28068) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 12): TypeError: Cannot read property 'schemaPath' of undefined
[Error - 11:55:18] Request textDocument/hover failed.
  Message: Request textDocument/hover failed with message: Cannot read property 'projectName' of undefined
  Code: -32603 
[Error - 11:55:18] Request textDocument/definition failed.
  Message: Request textDocument/definition failed with message: Cannot read property 'configDir' of undefined
  Code: -32603 

@tomitrescak
Copy link
Author

Sorry about one more message, my repo where it fails on windows but not on mac is here:

https://github.com/tomitrescak/corporator

@tomitrescak
Copy link
Author

tomitrescak commented Aug 10, 2018

I have debugged the plugin and the issue seems to be in GraphQLLanguageService.js file.
The project config is not detected. In following lines, the projectConfig is not defined

projectConfig = this._graphQLConfig.getConfigForFile(uri);
schemaPath = projectConfig.schemaPath;

When I log the uri it comes a bit scrambled in the beginning. Nevermind, it seems to be fine. Yet, the project config is not defined.

file:///c%3A/Users/Tomi/Documents/Drive/Github/apps/corporator/src/data/prisma/localisation.graphql

[EDIT] Further investigation showed that the error originates in the graphql-config package that improperly resolves windows paths. In getConfigForFile function the project.includesFile(filePath) return undefined as the filePath above is undetected for any of the projects.

I managed to solve this error, but this snowballed to other errors.

@divyenduz
Copy link
Contributor

@tomitrescak : Thanks for the details and your debugging efforts. This will be most likely be resolved by the latest beta coming today/tomorrow. Most likely because not tested on windows yet. I will automate testing on multiple OS in coming days. Thanks!

@ntziolis
Copy link

@tomitrescak I actually did create a repo for exactly this purpose, see here: graphql/vscode-graphql#21 (comment)

I'd be keen to know if this repo is working for you and if so which branch (local typescript version or vscode version)

@divyenduz
Copy link
Contributor

@ntziolis : Sure, I will visit this later today :)

@steebchen
Copy link

I have the same issue on Linux, so it seems that it's not necessarily windows specific. If you need more information please let me know.

@ntziolis
Copy link

@steebchen @tomitrescak Can you guys clone the following super minimal repo and let us know if you still see the issue? This way we can eliminate miss configuration as a cause.

Note: I was seeing the same issue, but after setting up the configuration from scratch it went away. Hence I created this bare metal repo for testing.

@steebchen
Copy link

@ntziolis I don't have this error on your repo, instead I'm getting Definition not found for GraphQL type String. Autocompletion works in .graphql files, it does not in .ts gql template strings.

@jvbianchi
Copy link

jvbianchi commented Aug 17, 2018

I'm having this problem too.
My .graphqlconfig:

{
  "projects": {
    "app": {
      "schemaPath": "generated/schema.graphql",
      "includes": ["src/graphql/**/*.graphql"],
      "extensions": {
        "endpoints": {
          "prod": "http://localhost:4000"
        }
      }
    }
  }
}

Versions:

Windows: 10 Pro
VSCode: 1.26.1
Extension: 0.0.10

Errors:

(node:10572) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Cannot read property 'schemaPath' of undefined
(node:10572) [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.
(node:10572) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): TypeError: Cannot read property 'schemaPath' of undefined
(node:10572) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 6): TypeError: Cannot read property 'schemaPath' of undefined
[Error - 1:14:36 PM] Request textDocument/hover failed.
  Message: Request textDocument/hover failed with message: Cannot read property 'projectName' of undefined
  Code: -32603 
[Error - 1:14:41 PM] Request textDocument/hover failed.
  Message: Request textDocument/hover failed with message: Cannot read property 'projectName' of undefined
  Code: -32603 

@bmfs
Copy link

bmfs commented Aug 30, 2018

I'm having the same issue in Mac

@tomitrescak
Copy link
Author

tomitrescak commented Aug 30, 2018

@ntziolis I am wondering whether Go To definition works for you in .graphql files, when you are defining your schema. I tried several repos and no love for me.

prisma/1.15.1 (darwin-x64) node-v10.9.0
graphql 2.16.5

@dontsave
Copy link

Having this issue also on windows

@beeplin
Copy link

beeplin commented Sep 30, 2018

Same issue here. Windows 10 1709. And as @tomitrescak said above, Go To Definition does not work, either.

@ganemone
Copy link
Contributor

It appears that the project key must be equal to the folder name in vscode. For example:

{
  "projects": {
    "folder-name": { <---- this needs to be the folder you are working on
      "schemaPath": "generated/schema.graphql",
      "includes": ["src/graphql/**/*.graphql"],
      "extensions": {
        "endpoints": {
          "prod": "http://localhost:4000"
        }
      }
    }
  }
}

@chanlito
Copy link

Facing this issue as well using vscode on MacOS.

@dfreeman
Copy link

I've run into this on macOS as well, and found that the issue was a space in my project path.

The configPath on the GraphQLConfig object is a plain file path, but the path being passed into getConfigForFile is a file: URI that (crucially) is urlencoded, e.g. ' ' -> '%20', and so no project matches.

@ph55
Copy link

ph55 commented Jan 10, 2019

Just installed plugin.
Same error

[Error - 6:19:54 PM] Request textDocument/hover failed.
  Message: Request textDocument/hover failed with message: Cannot read property 'projectName' of undefined
  Code: -32603

MacOS

@tomitrescak
Copy link
Author

I never made this work. Using the Apollo version now. It does not have the go to definition for server defined schemas but otherwise works nicely.

@DarkEye123
Copy link

DarkEye123 commented Jan 21, 2019

same here, tried all, nothing works.
my config.

{
  "projects": {
    "backend": {
      "schemaPath": "./src/schema.graphql",
      "includes": ["** /*.graphql"],
      "extensions": {
        "endpoints": {
          "default": "http://localhost:4444"
        }
      }
    },
    "prisma": {
      "schemaPath": "./src/generated/prisma.graphql",
      "includes": ["**/*.graphql"],
      "extensions": {
        "prisma": "prisma.yml"
      }
    }
  }
}

I noticed that 'schemaPath' thing occurs if prisma project is defined. If I remove it, it does not show UnhandledPromiseRejectionWarning and Request textDocument/hover failed. but error

Grammar is in an endless loop - Grammar is not advancing, nor is it pushing/popping is still present

@5achinJani
Copy link

5achinJani commented Mar 8, 2019

Having the same issue in macOS.
.graphqlconfig.yml

projects:
  my-app:
    schemaPath: src/schema.graphql
    includes: ["**/*.graphql"]
    extensions:
      endpoints:
        default: http://localhost:4000

my-app is project folder name.
Extension version : 0.1.7
VScode version : 1.32.1
Node version : v10.0.0 using via nvm.
"graphql-yoga": "1.17.4",
schemaPath points at right place.
Project type : JavaScript.

@ghost
Copy link

ghost commented Mar 15, 2019

Is there a fix for this issue?

@LeonardoGentile
Copy link

Same problem on osx:

{
  "projects": {
    "graphql-prisma": {
      "schemaPath": "prisma/datamodel.prisma",
      "includes": [
        "**/*.graphql",
        "**/*.gql"
      ],
      "excludes": [
        "temp/**"
      ],
      "extensions": {
        "endpoints": {
          "dev": "http://localhost:4000"
        }
      }
    }
  }
}

I get the output:

Error - 1:03:39 AM] Request textDocument/hover failed.
  Message: Request textDocument/hover failed with message: Cannot read property 'projectName' of undefined
  Code: -32603 

@Veetaha
Copy link

Veetaha commented May 1, 2019

Is there at least any workaround?

@jednano
Copy link

jednano commented Jul 25, 2019

I might have fixed this in kamilkisiela/graphql-config#124 by switching the config resolution to use cosmiconfig under the hood.

I'm having the same issue on MacOS.

@bkniffler
Copy link

Any news? Aparently v3.0.0-alpha.13 of graphql-config is out which resolves this issue. Apollo vsconfig extension eats up all my CPU unfortunately, so I was hoping on using prisma vsconfig, which does not work at all currently.

@magicmikex
Copy link

Anyone have a configuration the DOES work on windows? I have tried to get this one to work for 2 days and cant seem to get any configuration that will light up all the features. The documentation is very minimal and also conflicts with the documentation on the graphql config website. I am just about ready to give up.

@sairion
Copy link

sairion commented Dec 9, 2019

seeing same issue on mac os, not able to make this work

@sashaweiss
Copy link

Seeing the same issue on MacOS - anyone found a workaround?

@tomitrescak
Copy link
Author

The only way I made this work was to download SDL from playground and the use a local schema path

@dvakatsiienko
Copy link

Wow, the issue is still persists

@acao
Copy link
Member

acao commented Apr 19, 2022

Aparently v3.0.0-alpha.13 of graphql-config is out which resolves this issue

we are on graphql config 4 now so this should be resolved!

use schema instead of schemaPath. I do not see schemaPath in graphql config documentation anymore so it must be deprecated

@acao acao closed this as completed Apr 19, 2022
@acao acao added the lsp-server graphql-language-service-server label Apr 19, 2022
@acao acao transferred this issue from graphql/vscode-graphql Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lsp-server graphql-language-service-server
Projects
None yet
Development

No branches or pull requests