JetBrains / js-graphql-intellij-plugin

GraphQL language support for WebStorm, IntelliJ IDEA and other IDEs based on the IntelliJ Platform.
https://jimkyndemeyer.github.io/js-graphql-intellij-plugin/
MIT License
879 stars 97 forks source link

[NFR]: usage without schema file #472

Closed cyberhck closed 2 years ago

cyberhck commented 3 years ago

Hello there, First of all, I'd like to thank you for this plugin, it's a game changer.

I do have a feature I'd like to ask for, it might already exist, but I couldn't get it to work.

Basically, I have a graphql endpoint, when I create a .graphqlconfig file, and provide my endpoint, I can click on run button and it generates schema.graphql

However, I'd like to be able to do this without that step, for every file on that directory, I'd like it to provide intellisense by creating a schema file on temp dir if it's absolutely required.

Is this possible? or is it something you're looking for? That way I could just replace my GraphiQL web completely by my .graphql files.

Thanks in advance.

vepanimas commented 3 years ago

Hi @cyberhck! Thank you for using the plugin.

I'm not sure I fully understand what you're trying to achieve. You are not required to specify an endpoint to use a plugin at all, actually you can use it even without .graphqlconfig. Could you provide more details, please?

cyberhck commented 3 years ago

ahh, I didn't mean we can't use the plugin.

One of the most awesome thing about this plugin is recognizing types and providing intellisense.

Currently if I have a frequently changing backend, the only way to get intellisense and types being recognized is if I have a copy of schema locally (I generate using .graphql config and hit the run button)

Only when I do that my IDE starts to provide intellisense.

What I want to do is to be able to provide an endpoint, and have IDE generate schema on background everytime a .graphql file is opened (and provide a fetch schema button in case), that way even if my server has updated schema, I get it without having to click a button. (I mean strictly for intellisense and types being recognized)

Am I missing something? Can I already do this? If so, how?

cyberhck commented 3 years ago

reminding @vepanimas in case notification got lost somehow. Is there a solution?

vepanimas commented 3 years ago

Hi @cyberhck! Sorry for being silent, I spent all the time preparing a new release of this plugin.

Did I understand correctly that what is meant is rather not using without a schema at all, but periodically polling the server for the presence of a new schema in background?

cyberhck commented 3 years ago

Kinda, so currently if I don't have a schema, I basically can't write graphql queries, sure I can type without caring what IDE thinks, but that's same as writing in notepad for example.

Yes, your understanding is correct, I define a config (the normal way to define graphql config), when we open a .graphql file, IDE will look at which endpoint does it point to, and fetch using introspection query and keep it either in memory or in a temp file,

It doesn't have to keep fetching, we can fetch in two events:

vepanimas commented 3 years ago

Ok, I got it. But is there an issue with storing an introspection result schema in the project folder? What's wrong with the default workflow, when you specify a schema path in the config and this file is updated each time you run an introspection query? We can add a "re-fetch each N minutes and after some events" option and it will solve the issue, isn't it?

cyberhck commented 3 years ago

thing is my schema changes regularly, we're doing a federated graphql which means each team is free to update their schema (as the business requires) as long as it doesn't break existing schema. That's the same issue I have with postman, it also requires us to keep updating the SDL file, where as graphiql, playground, insomnia etc don't.

Instead of me having to click every once in a while, I just want this plugin to do it for me without me thinking about it too much :slightly_smiling_face:

cyberhck commented 3 years ago

if we were to automatically keep updating a schema file, that'd solve the issue yes, I could just point that schema to wherever I want, so yes, in theory it'll solve it :)

vepanimas commented 2 years ago

I found a similar issue, I close it in favor of the existing one https://github.com/jimkyndemeyer/js-graphql-intellij-plugin/issues/269.