graphql-for-vscode icon indicating copy to clipboard operation
graphql-for-vscode copied to clipboard

getting "graphql language server has stopped" message

Open mogarick opened this issue 5 years ago • 8 comments

I installed this plugin and then gql (yarn --dev add @playlyfe/gql) Then I created a simple index.js file for a graphql tutorial but the VSCode plugin is not woking. I'm getting an error indicator: screen shot 2018-10-04 at 6 06 43 pm when hover on it the next message displays: "Graphql language server has stopped" When I click o it the Graphql for VS Code output console opens with this content:

[Info  - 8:47:24 AM] NODE_PATH value is: /my/user/path/my-graphql-cp
[Info  - 8:47:28 AM] Module '@playlyfe/gql' loaded from: /my/user/path/my-graphql-cp/node_modules/@playlyfe/gql/lib/index.js

Here is the content of my .gqlconfig file

{
   "schema": {
     "files": "schemas/**/*.gql"
   },
   "query": {
     "files": [ /* define file paths which you'd like the gql parser to watch and give autocomplete suggestions for */
       {
         "match": "src/**/*.js", // for js
         "parser": ["EmbeddedQueryParser", { "startTag": "`", "endTag": "`" }]        
       }
     ]
   }
 } 

Here is the contents of my index.js file. the typeDefs is shown as a simple JS String

screen shot 2018-10-04 at 6 15 31 pm

const {GraphQLServer} = require("graphql-yoga");

const typeDefs = `
type Query {
    info: String!
    feed: [Link!]!
}

type Mutation {

}

type Link {
    id: ID!
    description: String!
    url: String!
}
`;

let links = [ {
    id: 'link-0',
    url: 'www.howtographql.com',
    description: 'Full stack tutorial for graphql'
}]


const resolvers = {
    Query: {
        info: () => `GraphQL CP`,
        feed: () => links

    }
    ,
    Link: {
        id: (root) => root.id,
        description: (root) => root.description,
        url: (root) => root.url
    }
}

const server = new GraphQLServer({
    typeDefs,
    resolvers
});

server.start(()=>console.log(`Server is running on http://localhost:4000`));

Is there a problem or do I need to config something else?

Thank you in advance.

mogarick avatar Oct 04 '18 23:10 mogarick

Have you installed watchman?

kumarharsh avatar Oct 05 '18 05:10 kumarharsh

It's globally installed.

$ watchman -v
4.7.0

mogarick avatar Oct 05 '18 12:10 mogarick

I'm having the same issue... :(

Aleksion avatar Oct 10 '18 18:10 Aleksion

@Aleksion @mogarick I was also having this issue. I resolved it by adding a package.json to my workspace with npm init and adding @playlyfe/gql (which I had already installed) to its dependencies:

{
  "name": "my-test-schema",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "dependencies": {},
  "devDependencies": {
    "@playlyfe/gql": "^2.6.0"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

abarger-bss avatar Dec 04 '18 16:12 abarger-bss

Also having this issue - instructions given definitely dont work. @playlyfe/gql tells to install globally - this plugin doesnt work unless a dev dependency.

bradennapier avatar Dec 07 '18 04:12 bradennapier

Also having this issue. @abarger-bss 's solution does nothing for me. Is there anybody who solved this issue?

ScripterSugar avatar Feb 20 '19 08:02 ScripterSugar

I don't have an actual solution, but I believe this could be because vscode is inheriting a different environment than your terminals, which is causing watchman to not be found in the path. I'll look into adding more diagnostics on those edge cases so that it can help you pinpoint issues better.

As a start, are all of you using Macs? I don't have a Mac, but on Windows, this issue occurs sometimes when I have run watchman from an Admin (elevated) Powershell, and have launched vscode via Start menu or from a non-elevated shell.

kumarharsh avatar Feb 20 '19 12:02 kumarharsh

@bradennapier - you should not install @playlyfe/gql globally - it should always be a dev dependency of your project. The instructions never mention installing the dependency globally, they have to be within the workspace root or a subfolder.

I've re-read the readme and might have missed out on such an instruction (or be blind to it!), so if you help me by pointing out where the docs cause you confusion, I can correct it so as not to cause future confusion to others. Thanks.

kumarharsh avatar Feb 20 '19 12:02 kumarharsh