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

feat: graphql-config@3 support in lsp server #1616

Merged
merged 8 commits into from
Aug 8, 2020

Conversation

acao
Copy link
Member

@acao acao commented Jul 15, 2020

  • load documents instead of includes
  • fix/adjust tests for [email protected] conversion
  • upgrade extensions implementation

Bonus

  • pre-load documents and schema cache on init
  • pre-load schema and type definitions cache on definition lookup (solves issues with "lazy definitions" in vscode-graphql)
  • add support for WorkspaceSymbolDefinitions
  • fix regression with variable definition completions regressions in variables completion #1622

Todo

This needs more tests!

@@ -296,11 +292,7 @@ export class GraphQLCache implements GraphQLCacheInterface {
}
const filesFromInputDirs = await this._readFilesFromInputDirs(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ardatan i had some questions about await project.loadDocuments(), as I think it could replace a lot of functionality we have in GraphQLCache. Our implementation has a different structure, where there is a collection item per file, and thus potentially multiple asts and other extracted data, whereas with Source[] it seems to be a collection of ASTs/strings with potentially entries with the same location file reference. I think we can at least get rid of our redundant logic to glob, read and parse files seperately here. There may be a bit of data missing for this to be accomplished, for which I can open a PR to graphql-config to add that data to these interfaces?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acao Sure! You can open a PR for that :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking into this further and I don't know if I'll need to actually!

paired with this PR, all of this is working:
https://github.com/prisma-labs/vscode-graphql/pull/184/files

however, there is some redunant logic between our GraphQLCache and MessageProcessor now, as of this PR, and I think I need to rewrite some of this. Either way, going to see if making it more graphql-config based in file loading will help! will definately make it more extensible!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ardatan the way that we cache some of the information about files, we need to store the range. it would be nice if there was a source.range in getDocuments() from which to compute offsets

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems i can address this issue with custom loader extensions as well. i need to be able to set specific parser configs as well. probably will be the solution in the long run

@acao acao force-pushed the 1615-graphql-config branch 2 times, most recently from 514c37f to 19b47f2 Compare July 26, 2020 13:23
@acao acao force-pushed the 1615-graphql-config branch from 22f7c2e to 2d747b6 Compare July 28, 2020 16:42
acao added 6 commits July 30, 2020 19:15
- load documents instead of 'includes"
- use latest patch version
- pre-cache schema more frequently
-fix messageProcessor test with config extensions
- updated test to use real cache/config instances
@acao acao force-pushed the 1615-graphql-config branch from 90dfb19 to 0b2e3c6 Compare July 30, 2020 23:17
@acao
Copy link
Member Author

acao commented Aug 2, 2020

I still want to add tests to this, and whats more, it's had no peer reviews or testing, and has a major impact on most of the GraphQL IDE ecosystem! the greatest impact is on the server, but there are some wide-reaching and important bugfixes, some of which I turned into some small but critical PRs here that I have merged. So I may release these and a few other patches as hotfix patch releases across the ecosystem before merging this PR as a minor version bump to everything but interface ideally - langauge server, lsp-cli, and thus vscode-graphql

@acao acao changed the title improvement: graphql config support in lsp server improvement: graphql-config@3 support in lsp server Aug 2, 2020
@acao acao force-pushed the 1615-graphql-config branch from 01188df to b05ef54 Compare August 7, 2020 15:29
move tmpdir default to logger
@acao acao force-pushed the 1615-graphql-config branch from b05ef54 to a067257 Compare August 7, 2020 15:54
@acao acao changed the title improvement: graphql-config@3 support in lsp server feat: graphql-config@3 support in lsp server Aug 8, 2020
@acao acao merged commit 27cd185 into graphql:main Aug 8, 2020
@acao acao deleted the 1615-graphql-config branch August 8, 2020 16:42
thenamankumar pushed a commit to thenamankumar/graphiql that referenced this pull request Aug 30, 2020
- adopt `documents` instead of `includes`, and other `graphql-config@3` features
- pre-cache schema on load and on `getDefinition`
- load schema from `project.getSchema()` by default or from individual files with config
- pre-cache all files in `documents` on initialization, which can be optionally disabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants