Mirror: TypeScript LSP plugin that finds GraphQL documents in your code and provides diagnostics, auto-complete and hover-information.

Account for non data properties in schema response (#84)

* more logs

* callout

Changed files
+11 -1
.changeset
packages
graphqlsp
+5
.changeset/sharp-planes-study.md
···
···
+
---
+
'@0no-co/graphqlsp': patch
+
---
+
+
catch more schema errors and improve logging
+2
packages/graphqlsp/README.md
···
workspace version of TypeScript. In VSCode you can do so by clicking the bottom right
when on a TypeScript file or adding a file like [this](https://github.com/0no-co/GraphQLSP/blob/main/packages/example/.vscode/settings.json).
### Configuration
- `schema` allows you to specify a url, `.json` or `.graphql` file as your schema
···
workspace version of TypeScript. In VSCode you can do so by clicking the bottom right
when on a TypeScript file or adding a file like [this](https://github.com/0no-co/GraphQLSP/blob/main/packages/example/.vscode/settings.json).
+
> If you are using VSCode ensure that your editor is using the Workspace Version of TypeScript
+
### Configuration
- `schema` allows you to specify a url, `.json` or `.graphql` file as your schema
+3 -1
packages/graphqlsp/src/graphql/getSchema.ts
···
.then(result => {
if (typeof result === 'string') {
logger(`Got error while fetching introspection ${result}`);
-
} else {
try {
ref.current = buildClientSchema(
(result as { data: IntrospectionQuery }).data
···
} catch (e: any) {
logger(`Got schema error for ${e.message}`);
}
}
});
} else {
···
.then(result => {
if (typeof result === 'string') {
logger(`Got error while fetching introspection ${result}`);
+
} else if (result.data) {
try {
ref.current = buildClientSchema(
(result as { data: IntrospectionQuery }).data
···
} catch (e: any) {
logger(`Got schema error for ${e.message}`);
}
+
} else {
+
logger(`Got invalid response ${JSON.stringify(result)}`);
}
});
} else {
+1
packages/graphqlsp/src/index.ts
···
info.project.projectService.logger.info(`[GraphQLSP] ${msg}`);
logger('config: ' + JSON.stringify(info.config));
if (!info.config.schema) {
throw new Error('Please provide a GraphQL Schema!');
}
···
info.project.projectService.logger.info(`[GraphQLSP] ${msg}`);
logger('config: ' + JSON.stringify(info.config));
if (!info.config.schema) {
+
logger('Missing "schema" option in configuration.');
throw new Error('Please provide a GraphQL Schema!');
}