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

Dart support for vscode-apollo and language-server #1385

Merged
merged 1 commit into from
Jul 25, 2019

Conversation

venkatd
Copy link
Contributor

@venkatd venkatd commented Jul 10, 2019

This resolves #1365.

Similar to how python handles this, adding support for graphql syntax highlighting and code completion using a basic function.

String gql(String x) => x;

var query = gql(r"""
query getPeople {
  allPeople {
    people {
      id
      birthYear
      created
    }
  }
}
""");

Screenshot of it in action:

image

I need a bit of guidance on building and testing the extension locally (including the language server). What's the process developers are typically using on vscode-apollo?

In order to test the functionality out, I patched the extension and language server directly in /Users/venkat/.vscode/extensions/apollographql.vscode-apollo-1.7.4. Then I applied those same changes to this repo. However I'd like to double check it all works.

@apollo-cla
Copy link

@venkatd: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

@venkatd venkatd force-pushed the vscode-dart-support branch 3 times, most recently from 9d6c545 to 47d3628 Compare July 10, 2019 12:51
"injectTo": [
"source.dart"
],
"scopeName": "inline.dart.python",
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this is wrong. You'd need it to be inline.graphql.dart. That fixed the highlighting issue for me :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤦‍♂️thanks for finding that! I ran the extension in debug mode with this change and everything worked.

@venkatd
Copy link
Contributor Author

venkatd commented Jul 15, 2019

@JakeDawkins looks like it all works when running in debug mode now :).

When I build the .vsix extension and install it like this, I get the following error:

[Error - 10:45:32 PM] Request textDocument/completion failed.
  Message: Request textDocument/completion failed with message: Cannot use GraphQLList "[Person]" from another module or realm.

Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.

https://yarnpkg.com/en/docs/selective-version-resolutions

Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.
  Code: -32603 

Could it be a conflict with running npm i and how lerna handles it? Will look into it further

@JakeDawkins
Copy link
Contributor

@venkatd I ran the same thing and it worked for me! You may need to uninstall any existing version of the extension and delete the extension cache for the install to work properly. At least if the VSIX file that's being generated is the same as a version you've previously installed.

rm -rf ~/.vscode/extensions/apollographql.vscode-apollo-1.7.5 with whatever version you're trying to install

@venkatd
Copy link
Contributor Author

venkatd commented Jul 22, 2019

@JakeDawkins thanks, I got it working! Cleared my cache, re-cloned the repo, and basically wiped the slate clean. I see now there are some merge conflicts. What's the preferred way to address them? Should I merge master into my branch or rebase?

@JakeDawkins
Copy link
Contributor

@venkatd If you could rebase this, that'd be great!

@venkatd venkatd force-pushed the vscode-dart-support branch 2 times, most recently from 6f5ce92 to 732c679 Compare July 25, 2019 20:37
@venkatd venkatd force-pushed the vscode-dart-support branch from 732c679 to 1b54e5d Compare July 25, 2019 20:50
@venkatd
Copy link
Contributor Author

venkatd commented Jul 25, 2019

@JakeDawkins just rebased and tested it out with a built .vsix extension again. Let me know if there's anything else needed before merge!

@JakeDawkins JakeDawkins merged commit 4fb2313 into apollographql:master Jul 25, 2019
@JakeDawkins
Copy link
Contributor

Thanks so much for the work (and the patience) @venkatd! Just released with v1.9.0 of the extension!

@venkatd
Copy link
Contributor Author

venkatd commented Jul 26, 2019

@JakeDawkins thanks for the guidance along the way and glad it's in the new release! Just tried the official upgrade all looks to be working.

essaji pushed a commit to essaji/apollo-tooling that referenced this pull request Aug 25, 2019
@AlexKenbo
Copy link

@JakeDawkins thanks for the guidance along the way and glad it's in the new release! Just tried the official upgrade all looks to be working.

Tell me how to set it up?
I only have a schematic - will this work?

@venkatd
Copy link
Contributor Author

venkatd commented Sep 24, 2020

@AlexKenbo the dart-specific setup just requires you to define a function like this:

String gql(String query) => query;

Because it will interpret anything like so as GraphQL:

gql("""
query getData {
...
}
""")

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.

Add support for dart in vscode-dart
4 participants