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

graphql-monaco is broken on monaco 0.21+ #1791

Closed
djpate opened this issue Feb 8, 2021 · 10 comments
Closed

graphql-monaco is broken on monaco 0.21+ #1791

djpate opened this issue Feb 8, 2021 · 10 comments

Comments

@djpate
Copy link

djpate commented Feb 8, 2021

Trying to install graphql-mocaco using the latest versions of monaco-editor will not work.

Tested broken on 0.22 and 0.21. The version in the example works fine (0.20)

The rest call to the graphql endpoint to do the introspection query does not fire either.

I tried looking at their changelog but could not find something that would be a clear reason why.

@acao
Copy link
Member

acao commented Feb 8, 2021

yes, when the mode fails then the worker is not initialized

this is a known bug, thanks for reporting! i thought i had created a ticket this weekend

@acao acao added the bug label Feb 8, 2021
@Nishchit14
Copy link
Contributor

Nishchit14 commented Sep 17, 2021

I am using monaco-editor@0.27.0 and facing the same issue. @acao any plan to support it in near future? I really appreciate all the work done for monaco-graphql. If I can help anyway then please do let me know.

@Nishchit14
Copy link
Contributor

I am getting the error, monaco is not defined

image

@acao
Copy link
Member

acao commented Sep 17, 2021

I'm hoping to get to it soon! There are some more urgent matters currently, but this was one of the next known issues to address.

So, here, I am using a pattern borrowed from the monaco examples:

https://github.com/microsoft/monaco-editor/search?q=CompletionItemKind

it must be that previously, monaco 0.20 and older were exporting this globally? I don't know how this worked before hahaha

I can't seem to figure out where to import this enum from now:

https://github.com/microsoft/monaco-editor/blob/a40145a4c9ee7f003e5b7dcbc98c567a8dadc158/typedoc/monaco.d.ts#L5700

here is a sandbox where I tried to import it:

https://codesandbox.io/s/async-flower-nl2kb?file=/src/index.ts

@Nishchit14
Copy link
Contributor

great, thanks for replying quickly @acao. I'll try to help here by debugging it with the above references.

@Nishchit14
Copy link
Contributor

Nishchit14 commented Sep 20, 2021

I have cloned this monaco-samples repo and try to debug apis of monaco-editor@0.27.0.

https://github.com/microsoft/monaco-editor-samples/blob/main/browser-esm-webpack-typescript/src/index.ts#L1

import * as monaco from 'monaco-editor';

console.log(
	monaco.languages.CompletionItemKind,
	"monaco.languages.CompletionItemKind"
);

console output is here

image

Maybe we can access the CompletionItemKind language API directly importing monaco-editor shown in the above code snippet.

The type definition is here https://microsoft.github.io/monaco-editor/api/enums/monaco.languages.completionitemkind.html

I hope it will help someway @acao, please do let me your thoughts on it :)

@acao
Copy link
Member

acao commented Sep 20, 2021

ah nice, of course that would work!

so I think you can just add that line to the top of the file then:

import * as monaco from 'monaco-editor';

@Nishchit14
Copy link
Contributor

@acao done 🚀 , passing to you PR #1952

@Nishchit14
Copy link
Contributor

If I set globalAPI: true in MonacoWebpackPlugin then It works for monaco-editor@0.27.0. This option exposes monaco object globally. do we need to still work on PR #1952? @acao

  new MonacoWebpackPlugin({
      // available options are documented at https://github.com/Microsoft/monaco-editor-webpack-plugin#options
      globalAPI: true,
      publicPath: "/js/",
      filename: "[name].worker.bundle.js",
      languages: [
        'javascript',
        'html',
        'typescript',
        'json'
      ]
    })

@acao
Copy link
Member

acao commented Oct 29, 2021

#1952 is released, and I will soon release #1979 which will resolve other issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

3 participants