Skip to content

Commit

Permalink
endpoints extension working properly
Browse files Browse the repository at this point in the history
  • Loading branch information
acao committed Jun 23, 2023
1 parent 0b4e2dc commit 821ec95
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 31 deletions.
37 changes: 36 additions & 1 deletion packages/vscode-graphql-execution/esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,42 @@ build({
minify: arg === '--minify',
platform: 'node',
outdir: 'out/',
external: ['vscode', 'ts-node', 'tslib'],
external: [
'squirrelly',
'teacup',
'coffee-script',
'marko',
'slm',
'vash',
'plates',
'babel-core',
'htmling',
'ractive',
'mote',
'eco',
'jqtpl',
'hamljs',
'jazz',
'hamlet',
'whiskers',
'haml-coffee',
'hogan.js',
'templayed',
'walrus',
'mustache',
'just',
'ect',
'toffee',
'twing',
'dot',
'bracket-template',
'vscode',
'velocityjs',
'dustjs-linkedin',
'atpl',
'liquor',
'twig',
],
format: 'cjs',
sourcemap: true,
watch: isWatchMode,
Expand Down
26 changes: 6 additions & 20 deletions packages/vscode-graphql-execution/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@
"Programming Languages"
],
"activationEvents": [
"onCommand:vscode-graphql-execution.contentProvider.isDebugging",
"onCommand:vscode-graphql-execution.contentProvider.contentProvider",
"onLanguage:graphql",
"workspaceContains:**/.graphqlrc",
"workspaceContains:**/.graphqlconfig",
"workspaceContains:**/.graphqlrc.{json,yaml,yml,js,ts,toml}",
"workspaceContains:**/graphql.config.{json,yaml,yml,js,ts,toml}",
"workspaceContains:**/package.json",
"onCommand:vscode-graphql-execution.isDebugging",
"onCommand:vscode-graphql-execution.contentProvider",
"onLanguage:graphql"
"workspaceContains:**/package.json"
],
"contributes": {
"commands": [
Expand Down Expand Up @@ -84,7 +83,8 @@
},
"homepage": "https://github.com/graphql/graphiql/blob/main/packages/vscode-graphql-execution/README.md",
"scripts": {
"vsce:package": "vsce package --yarn",
"compile": "node esbuild.js",
"vsce:package": "yarn compile && vsce package --yarn",
"vsce:prepublish": "npm run vsce:package",
"vsce:publish": "vsce publish --yarn",
"open-vsx:publish": "ovsx publish --yarn -i . --pat $OVSX_PAT",
Expand Down Expand Up @@ -113,19 +113,5 @@
"graphql": "16.6.0",
"nullthrows": "1.1.1",
"@graphql-tools/code-file-loader": "8.0.1"
},
"workspaces": {
"nohoist": [
"graphql",
"graphql-config",
"dotenv",
"graphql-ws",
"graphql-tag",
"@urql/core",
"ws",
"nullthrows",
"capitalize",
"@whatwg-node/fetch"
]
}
}
13 changes: 5 additions & 8 deletions packages/vscode-graphql-execution/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function activate(context: ExtensionContext) {
registerCodeLens();
// }

// let commandContentProvider: Disposable;
let commandContentProvider: GraphQLContentProvider;

const registerContentProvider = () => {
return commands.registerCommand(
Expand All @@ -78,18 +78,18 @@ export function activate(context: ExtensionContext) {
{},
);

const contentProvider = new GraphQLContentProvider(
commandContentProvider = new GraphQLContentProvider(
uri,
outputChannel,
literal,
panel,
);
const registration = workspace.registerTextDocumentContentProvider(
'graphql',
contentProvider,
commandContentProvider,
);
context.subscriptions.push(registration);
panel.webview.html = contentProvider.getCurrentHtml();
panel.webview.html = commandContentProvider.getCurrentHtml();
},
);
};
Expand All @@ -104,14 +104,11 @@ export function activate(context: ExtensionContext) {
// // }
// });
workspace.onDidSaveTextDocument(async e => {
await window.showErrorMessage('saved');
if (
e.fileName.includes('graphql.config') ||
e.fileName.includes('graphqlrc')
) {
provider.dispose();
const newProvider = registerContentProvider();
context.subscriptions.push(newProvider);
await commandContentProvider.loadConfig();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import { loadConfig, GraphQLProjectConfig } from 'graphql-config';
import { visit, VariableDefinitionNode } from 'graphql';
import { NetworkHelper } from '../helpers/network';
import { SourceHelper, GraphQLScalarTSType } from '../helpers/source';
import { LanguageServiceExecutionExtension } from '../helpers/extensions';
import {
LanguageServiceExecutionExtension,
EndpointsExtension,
} from '../helpers/extensions';

import type { Endpoint, Endpoints } from '../helpers/extensions';
import type { ExtractedTemplateLiteral } from '../helpers/source';
Expand Down Expand Up @@ -255,7 +258,7 @@ export class GraphQLContentProvider implements TextDocumentContentProvider {
throwOnEmpty: false,
throwOnMissing: false,
legacy: true,
extensions: [LanguageServiceExecutionExtension],
extensions: [LanguageServiceExecutionExtension, EndpointsExtension],
});
this._projectConfig = config?.getProjectForFile(literal.uri);

Expand Down

0 comments on commit 821ec95

Please sign in to comment.