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
CM6 support for codemirror-graphql #2022
Comments
;) |
any support for that would be more than welcome! i’m deep into preparing monaco-graphql for graphiql/playground 2.0, but we have contributors and co-maintainers who care a whole lot about codemirror-graphql, and considering they are both using the same underlying language service libraries, they will continue to improve one another |
Adding support for CM6 would be great. I can try to support any efforts on this but unfortunately can't commit to picking this up this week. I should be able to do so by next week though if it isn't already being implemented by then. |
Implemented the codemirror.next legacy mode support for graphql mode. This only covers syntax highlighting. Autocomplete, jump and info extensions still need to be implemented to have feature parity with Codemirror v5. From #2022
I've added support for the stream parser. This only handles basic syntax highlighting. |
To have support for all the other features, we would need to implement a Parser class. The current parser in I think we can potentially transform the graphql language service parser to support the lezer Parser following a similar approach in the markdown lang. |
Amazing thank you so much! Really appreciate the swift response. Any plans to publish that package to NPM? Even just the basic syntax highlighting would be great. |
Implemented the codemirror.next legacy mode support for graphql mode. This only covers syntax highlighting. Autocomplete, jump and info extensions still need to be implemented to have feature parity with Codemirror v5. From #2022
released! 🥳 thanks @imolorhe ! |
thanks so much! Super excited for this. However, just to let you know I think there may have been an issue publishing the package as I'm getting a "module not found" error when I try to import from Indeed, when I dig into node_modules, I don't see a When I cloned the example from this repo it worked because it's pulling in the package locally here: https://github.com/graphql/graphiql/blob/main/examples/cm6-graphql-parcel/package.json#L27 However, if you replace that line with the latest version published on npm the build will fail since the module fails to resolve. Have a repl with a minimal repro here: https://replit.com/@SergeiChestakov/cm6-gql (hosted at https://cm6-gql.sergeichestakov.repl.co/) |
Right.. I was supposed to add cm6-legacy to the files list in package.json. Verified locally with |
Created PR with the fix |
btw should the version of CM in this package's peer dependencies be updated to support CM6:
|
yes, I also plan on upgrading |
FYI we're using this in production now :) You can see it in action here: https://replit.com/@SergeiChestakov/gql-example?v=1 Thanks again! 😄 |
Oh wow.. it was for repl.it. Nice! |
FYI we also released the full codemirror 6 graphql support with autocompletion, etc. https://www.npmjs.com/package/cm6-graphql |
Amazing thank you! Will give it a try 😄 |
-- Reason, error with CM6 (graphql/graphiql#2022). Advanced output (yarn build for project https://github.com/usalko/graphiql.git#js): yarn run v1.22.19 $ yarn build:clean && yarn build:cm6-graphql && yarn build:packages && yarn build:graphiql-react && yarn build:graphiql-plugin-explorer && yarn build:graphiql-plugin-code-exporter && yarn build:graphiql $ yarn tsc --clean && yarn tsc --clean resources/tsconfig.graphiql.json $ tsc --build --clean $ tsc --build --clean resources/tsconfig.graphiql.json $ yarn workspace cm6-graphql run build $ cm-buildhelper src/index.ts error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. error Command failed. Exit code: 1 Command: /home/vanya/.nvm/versions/node/v16.17.1/bin/node Arguments: /home/vanya/.nvm/versions/node/v16.17.1/lib/node_modules/yarn/lib/cli.js run build Directory: /home/vanya/projects/web/eu/research/graphiql/packages/cm6-graphql Output: info Visit https://yarnpkg.com/en/docs/cli/workspace for documentation about this command. error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
-- Reason, error with CM6 (graphql/graphiql#2022). Advanced output (yarn build for project https://github.com/usalko/graphiql.git#js): yarn run v1.22.19 $ yarn build:clean && yarn build:cm6-graphql && yarn build:packages && yarn build:graphiql-react && yarn build:graphiql-plugin-explorer && yarn build:graphiql-plugin-code-exporter && yarn build:graphiql $ yarn tsc --clean && yarn tsc --clean resources/tsconfig.graphiql.json $ tsc --build --clean $ tsc --build --clean resources/tsconfig.graphiql.json $ yarn workspace cm6-graphql run build $ cm-buildhelper src/index.ts error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. error Command failed. Exit code: 1 Command: /home/vanya/.nvm/versions/node/v16.17.1/bin/node Arguments: /home/vanya/.nvm/versions/node/v16.17.1/lib/node_modules/yarn/lib/cli.js run build Directory: /home/vanya/projects/web/eu/research/graphiql/packages/cm6-graphql Output: info Visit https://yarnpkg.com/en/docs/cli/workspace for documentation about this command. error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@imolorhe that package doesn't work with module import. The deps required for using |
@imolorhe Does this new package provide error messages and auto complete based on the schema? Difficult to understand because there are no instructions in the package. |
Yes it does. Sorry I'll try to draft a README for the package soon |
@imolorhe Thanks for the quick response. I've got something working now. My only outstanding concern is supporting a "variable" editor. I see in graphiql which uses code mirror 5 there is a "graphql-variable" mode. I had a look inside this new package which support cm6 but can't see anything similar? |
No there is nothing similar for codemirror 6 |
Hey there!
I was looking to add graphql support to our app which uses CodeMirror 6 and stumbled upon the
codemirror-graphql
package in this repo. However, it looks like that package only works for CodeMirror 5 and is therefore not compatible with CM6. I also couldn't find any alternatives that do work with CM6.I saw that there was a way to use CM5 language packages in CM6 (e.g. the modes in this repo: https://github.com/codemirror/legacy-modes/) but only if they implement the
StreamParser
interface which I don't think is the case here.Just wondering if there were any plans to add support for CM6 in the
codemirror-graphql
package. Happy to help out in this effort myself as well and open up a PR if this is something you guys want and no one else can pick it up.Thanks in advanced!
The text was updated successfully, but these errors were encountered: