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

Syntax error in typeDefs #2151

Open
Mangatt opened this issue Jan 23, 2022 · 4 comments
Open

Syntax error in typeDefs #2151

Mangatt opened this issue Jan 23, 2022 · 4 comments
Labels

Comments

@Mangatt
Copy link

Mangatt commented Jan 23, 2022

Actual Behavior

Simple typeDefs.gql file throws Syntax Error: Expected Name, found "}".GraphQL: Syntax

type Test {
	id: ID!
}

type Query {
	test(id: ID!): Test
}

Expected Behavior

There should not be an error.

Steps to Reproduce the Problem Or Description

Create file with contents above.

Specifications

  • GraphQL for VSCode Extension Version: 0.3.41
  • VSCode Version: 1.63.2
  • OS Name: Win 10
  • OS Version: 21H2
  • graphql config filename and format example: .graphqlrc
{
  "schema": "http://localhost:4000/graphql",
  "documents": "packages/*/src/**/*.{graphql,gql,js,ts,jsx,tsx}",
  "extensions": {
  	"endpoints": {
  		"default": {
  			"url": "http://localhost:4000"
  		}
  	}
  }
}

Logs Of TS Server || GraphQL Language Service

@ragokan
Copy link

ragokan commented Jan 23, 2022

I am having same error

@acao acao transferred this issue from graphql/vscode-graphql Feb 2, 2022
@acao acao added the bug label Feb 2, 2022
@acao
Copy link
Member

acao commented Feb 2, 2022

thanks for the heads up! this might have to do with the graphql-config upgrade.

moving to the LSP repository since this is related to the language server

@acao acao added the lsp-server graphql-language-service-server label Feb 2, 2022
@acao
Copy link
Member

acao commented Feb 2, 2022

@Mangatt @ragokan to explain what is happening, graphql-config loadDocuments() on startup and on file save events is scanning your entire documents tree, and throws an exception when parsing an incomplete graphql string in a file that isn't even open in vscode.

Note that this only happens when documents config option is used.

This is because graphql-config uses graphql-tools loaders which use graphql-js parse() under the hood, thus the familiar graphql validation error. There are a lot of efficiencies we hope to introduce here but its hard to test the dozens of edge cases every time.

So for now, we just need to trap and ignore graphql-config loadDocuments() exceptions

@dotansimha how do you suggest we handle these exceptions moving forward?

When we use our internal findGraphQLTags implementation, we use graphql-language-service-parser to parse all the files and build object/fragment/etc definition caches, which handles incomplete graphql strings

@mmmulani
Copy link

I'm running into this issue with a .graphqlrc.yml file of:

# .graphqlrc.yml
schema: "shared/schema.graphql"

where documents is not specified but instead a single schema file is.

Anyone have a workaround for this? It doesn't seem like there's a setting in the graphql extension but possibly vscode has a setting to disable showing these errors?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants