GraphQL Auto Completion

Issue #2467 open
Tony White created an issue

With GraphQL now available in LWC (https://developer.salesforce.com/docs/platform/lwc/guide/reference-graphql.html) would be good to be able to have autocompletion for objects and fields etc

Comments (5)

  1. Scott Wells repo owner

    Just leaving myself a few notes for when I circle back around to this. First, there’s a GraphQL plugin from JetBrains that minimally provides syntax highlighting, formatting, etc.:

    https://plugins.jetbrains.com/plugin/8097-graphql

    It looks like it can be extended to understand specific GraphQL schemas:

    https://github.com/JetBrains/js-graphql-intellij-plugin

    and the Salesforce Query GraphQL schema is documented here:

    https://developer.salesforce.com/docs/platform/graphql/guide/schema-conventions.html

  2. Scott Wells repo owner

    I’ve been tinkering with this and it’s actually more complex than I’d originally thought/hoped. Creating a GraphQL schema for the basics is pretty straightforward, though I haven’t yet been able to determine how exactly to register it programmatically to be used in the specific LWC gql context. Beyond that, though, it’s not a static schema anyway because SObjects types and their fields are actually part of the schema definition. I confess that I’m not at all an expert (understatement) on GraphQL schema definitions, but it doesn’t appear that they can be quite that dynamic. As a result, it looks like I’d have to generate a schema alongside the OST so that it properly includes the expected types and fields. And like I said, even then, I’m not sure how I’d be able to register it with the JetBrains GraphQL plugin.

    What I have done for the next build, though, is implemented an inspection suppressor for the GraphQL plugin to ensure that gql queries don’t end up painted red, e.g.:

    While that’s far from complete/perfect, it does allow users to install and use the GraphQL plugin for syntax highlighting, formatting, grammar-based validation, etc., of these queries even if completion and semantic validation aren’t available.

  3. Log in to comment