Skip to content

Commit

Permalink
Add support for GraphQL in Notebooks (#236)
Browse files Browse the repository at this point in the history
* Add support for GraphQL in Notebooks

* Add changeset
  • Loading branch information
pubmodmatt authored Oct 31, 2024
1 parent 7e8130b commit 9a4403d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/wise-gorillas-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vscode-apollo": minor
---

Add support for GraphQL in Notebook cells
1 change: 1 addition & 0 deletions src/language-server/project/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const fileAssociations: { [extension: string]: string } = {
".re": "reason",
".ex": "elixir",
".exs": "elixir",
".ipynb": "python",
};

export interface GraphQLInternalProjectConfig extends GraphQLProjectConfig {
Expand Down
11 changes: 5 additions & 6 deletions src/language-server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,14 @@ connection.onInitialized(async () => {
});

const documents = new TextDocuments(TextDocument);
const schemes = ["file", "vscode-notebook-cell"];

// Make the text document manager listen on the connection
// for open, change and close text document events
documents.listen(connection);

function isFile(uri: string) {
return URI.parse(uri).scheme === "file";
function isEnabledDocument(uri: string) {
return schemes.includes(URI.parse(uri).scheme);
}

documents.onDidChangeContent((params) => {
Expand All @@ -173,8 +174,7 @@ documents.onDidChangeContent((params) => {
);
if (!project) return;

// Only watch changes to files
if (!isFile(params.document.uri)) {
if (!isEnabledDocument(params.document.uri)) {
return;
}

Expand Down Expand Up @@ -213,8 +213,7 @@ connection.onDidChangeWatchedFiles((params) => {
continue;
}

// Only watch changes to files
if (!isFile(uri)) {
if (!isEnabledDocument(uri)) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion src/tools/utilities/languageInformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const minimumKnownExtensions: Record<
typescriptreact: [".tsx"],
vue: [".vue"],
svelte: [".svelte"],
python: [".py"],
python: [".py", ".ipynb"],
ruby: [".rb"],
dart: [".dart"],
reason: [".re"],
Expand Down

0 comments on commit 9a4403d

Please sign in to comment.