apollographql / apollographql/apollo-tooling

GraphQLError: Syntax Error: Expected "schema", found String "Represents a schema"

Open
#2,453 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3k
Forks
460
PR merge metrics
No merged PRs in 30d

Description

**Intended outcome:**

Extension works

**Actual outcome:**

```
GraphQLError: Syntax Error: Expected "schema", found String "Represents a schema"
at syntaxError (/home/codespace/.vscode-remote/extensions/apollographql.vscode-apollo-1.19.6/node_modules/graphql/error/syntaxError.js:15:10)
at Parser.expectKeyword (/home/codespace/.vscode-remote/extensions/apollographql.vscode-apollo-1.19.6/node_modules/graphql/language/parser.js:1435:42)
at Parser.parseSchemaDefinition (/home/codespace/.vscode-remote/extensions/apollographql.vscode-apollo-1.19.6/node_modules/graphql/language/parser.js:738:10)
at Parser.parseTypeSystemDefinition (/home/codespace/.vscode-remote/extensions/apollographql.vscode-apollo-1.19.6/node_modules/graphql/language/parser.js:690:23)
at Parser.parseDefinition (/home/codespace/.vscode-remote/extensions/apollographql.vscode-apollo-1.19.6/node_modules/graphql/language/parser.js:154:19)
at Parser.many (/home/codespace/.vscode-remote/extensions/apollographql.vscode-apollo-1.19.6/node_modules/graphql/language/parser.js:1518:26)
at Parser.parseDocument (/home/codespace/.vscode-remote/extensions/apollographql.vscode-apollo-1.19.6/node_modules/graphql/language/parser.js:111:25)
at Object.parse (/home/codespace/.vscode-remote/extensions/apollographql.vscode-apollo-1.19.6/node_modules/graphql/language/parser.js:36:17)
at FileSchemaProvider.loadFileAndGetDocument (/home/codespace/.vscode-remote/extensions/apollographql.vscode-apollo-1.19.6/lib/language-server/providers/schema/file.js:57:30)
at FileSchemaProvider.resolveSchema (/home/codespace/.vscode-remote/extensions/apollographql.vscode-apollo-1.19.6/lib/language-server/providers/schema/file.js:23:21) {
locations: [ { line: 1, column: 1 } ]
}
```

**How to reproduce the issue:**

1. Use elixir absinthe to generate a schema document
2. Start vscode

**Versions**

Here's the schema:

```
"Represents a schema"
schema {
query: RootQueryType
mutation: RootMutationType
subscription: RootSubscriptionType
}
```

As far as I know this should be valid.

Contributor guide

Open the contributing guide

Research direction

Start at lib/language-server/providers/schema/file.js, especially FileSchemaProvider.loadFileAndGetDocument, and reproduce the failure with the Absinthe-generated schema shown in the issue. Check how the GraphQL parser handles the leading schema description; done means the extension accepts this schema without the reported syntax error.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.