Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Fix VS Code extension issue by sending a different GQL query for VSCE#40621

Merged
philipp-spiess merged 10 commits into
mainfrom
ps/fix-vscode-issue
Aug 22, 2022
Merged

Fix VS Code extension issue by sending a different GQL query for VSCE#40621
philipp-spiess merged 10 commits into
mainfrom
ps/fix-vscode-issue

Conversation

@philipp-spiess

@philipp-spiess philipp-spiess commented Aug 19, 2022

Copy link
Copy Markdown
Contributor

A recent change changed one of the GraphQL queries that the VS Code extension is using to add a new field that was only recently added to the GraphQL backend (c.f. here).

This unfortunately is not available on "older" server versions including 3.42.1. This means that every person that updates their VS Code extension release now and is on an on-prem server that lags a bit behind will see the search broken.

We do not yet have a system to get the server version and make decisions based on it so I decide to fix it by reverting to the previous query in the VS Code environment (the backend is written in a way that it can handle older clients, just not the other way around).

Test plan

I verified that this fixes the VSCE issue by running a query against 3.42.1.

Screenshot 2022-08-19 at 20 14 33

App preview:

Check out the client app preview documentation to learn more.

@philipp-spiess philipp-spiess added bug An error, flaw or fault that produces an incorrect or unexpected result, or behavior. vscode-extension labels Aug 19, 2022
@philipp-spiess philipp-spiess added this to the Integrations 16 milestone Aug 19, 2022
@philipp-spiess philipp-spiess requested review from a team, olafurpg and taras-yemets August 19, 2022 18:26
@philipp-spiess philipp-spiess self-assigned this Aug 19, 2022
@cla-bot cla-bot Bot added the cla-signed label Aug 19, 2022
// GraphQL
const graphQL: typeof sourcegraph['graphQL'] = {
execute: (query, variables) => clientAPI.requestGraphQL(query, variables),
execute: ((query: any, variables: any) => clientAPI.requestGraphQL(query, variables)) as any,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have absolutely no clue why but my VS Code builds kept on erroring here:

  ERROR in /Users/philipp/dev/sourcegraph/client/shared/src/api/extension/extensionApi.ts
  ../shared/src/api/extension/extensionApi.ts 307:39-81
  [tsl] ERROR in /Users/philipp/dev/sourcegraph/client/shared/src/api/extension/extensionApi.ts(307,40)
        TS2322: Type 'Promise<SuccessGraphQLResult<any>> | Promise<ErrorGraphQLResult<any>>' is not assignable to type 'Promise<GraphQLResult<TResult>>'.
    Type 'Promise<ErrorGraphQLResult<any>>' is not assignable to type 'Promise<GraphQLResult<TResult>>'.
      Type 'ErrorGraphQLResult<any>' is not assignable to type 'GraphQLResult<TResult>'.
        Type 'ErrorGraphQLResult<any>' is not assignable to type 'ErrorGraphQLResult<TResult>'.
          Types of property 'errors' are incompatible.
            Type 'readonly import("/Users/philipp/dev/sourcegraph/node_modules/graphql/error/GraphQLError").GraphQLError[]' is not assignable to type 'readonly import("/Users/philipp/dev/sourcegraph/client/vscode/code-intel-extensions/node_modules/graphql/error/GraphQLError").GraphQLError[]'.
              Type 'import("/Users/philipp/dev/sourcegraph/node_modules/graphql/error/GraphQLError").GraphQLError' is not assignable to type 'import("/Users/philipp/dev/sourcegraph/client/vscode/code-intel-extensions/node_modules/graphql/error/GraphQLError").GraphQLError'.
                Types of property 'extensions' are incompatible.
                  Type '{ [key: string]: any; } | undefined' is not assignable to type '{ [key: string]: any; }'.
                    Type 'undefined' is not assignable to type '{ [key: string]: any; }'.

  webviews compiled in 325978 ms
[19:23:35] 'webpack' errored after 5.43 min

Since there was no other way to build main, I decide to merge this upstream. Extension API seems like something we will soon remove anyways!

"sourcegraph/verilog",
"sourcegraph/vhdl"
]
["sourcegraph/apex","sourcegraph/clojure","sourcegraph/cobol","sourcegraph/cpp","sourcegraph/csharp","sourcegraph/cuda","sourcegraph/dart","sourcegraph/elixir","sourcegraph/erlang","sourcegraph/go","sourcegraph/graphql","sourcegraph/groovy","sourcegraph/haskell","sourcegraph/java","sourcegraph/jsonnet","sourcegraph/kotlin","sourcegraph/lisp","sourcegraph/lua","sourcegraph/ocaml","sourcegraph/pascal","sourcegraph/perl","sourcegraph/php","sourcegraph/powershell","sourcegraph/protobuf","sourcegraph/python","sourcegraph/r","sourcegraph/ruby","sourcegraph/rust","sourcegraph/scala","sourcegraph/shell","sourcegraph/starlark","sourcegraph/strato","sourcegraph/swift","sourcegraph/tcl","sourcegraph/thrift","sourcegraph/typescript","sourcegraph/verilog","sourcegraph/vhdl"] No newline at end of file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This diff was always created when I ran yarn build-vsce so we might as well keep it in main.

@philipp-spiess philipp-spiess requested a review from umpox August 19, 2022 18:37
Comment thread client/shared/src/backend/file.ts Outdated
},
request: !IS_VSCE
? gql`
query HighlightedFile(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: can we extract these large literals into toplevel consts with some helpful variable name and a comment explaining what this query is used for?

@olafurpg olafurpg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for looking into this! LGTM 👍 just a minor nit suggestion

@philipp-spiess philipp-spiess merged commit e852570 into main Aug 22, 2022
@philipp-spiess philipp-spiess deleted the ps/fix-vscode-issue branch August 22, 2022 08:13
@vdavid vdavid removed this from the Integrations 16 milestone Oct 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug An error, flaw or fault that produces an incorrect or unexpected result, or behavior. cla-signed vscode-extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants