Skip to content

Commit

Permalink
fix: initial request cache set, import tsc bugs (#1266)
Browse files Browse the repository at this point in the history
- `handleDidOpenOrSaveNotification` didn't have all param types factored in, leading to retrieving textDocument.text from the wrong place
- by fixing this, the cache is set properly. before, after typescript conversion, initial file cache was not set, only on a valid change would cache set
- fix how imports of node modules happen so that the tsc compiler is happy
- fix prepublish so that it doesnt run the whole shebang on every `yarn` or `yarn add`
- add CI for

* chore: try moving ci to actions
  • Loading branch information
acao committed Jan 26, 2020
1 parent 599610a commit 6b98f8a
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 59 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Node.JS CI
on: [push]
jobs:
test:
runs-on: ubuntu-latest
name: lint & test
steps:
- uses: actions/checkout@v1
- uses: bahmutov/npm-install@v1
- run: yarn ci
e2e:
runs-on: ubuntu-latest
name: cypress
steps:
- uses: actions/checkout@v1
- uses: bahmutov/npm-install@v1
- run: yarn ci-e2e
File renamed without changes.
16 changes: 0 additions & 16 deletions .github/workflows/issue.yml

This file was deleted.

16 changes: 16 additions & 0 deletions .github/workflows/issue.yml.archived
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# name: "Issues"
# on:
# issues:
# types: [closed]
# jobs:
# build:
# runs-on: ubuntu-latest
# steps:
# - name: Discord Notification - Issues
# env:
# DISCORD_WEBHOOK: ${{ secrets.DISCORD_WH_GRAPHIQL_GENERAL }}
# uses: Ilshidur/action-discord@master
# with:
# args: 'Issue [{{ EVENT_PAYLOAD.issue.title }}]({{ EVENT_PAYLOAD.issue.html_url }}) {{ EVENT_PAYLOAD.action }} by [@{{ EVENT_PAYLOAD.issue.user.login }}]({{ EVENT_PAYLOAD.issue.user.html_url }})'


24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build]
command = "yarn build-bundles && yarn build-demo && yarn build-docs"
command = "yarn build && yarn build-bundles && yarn build-demo && yarn build-docs"
publish = "packages/graphiql"
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"scripts": {
"build": "yarn run build-clean && yarn build-ts-cjs && yarn build-babel",
"build-babel": "lerna run build --scope codemirror-graphql",
"build-babel": "yarn workspace codemirror-graphql run build",
"build-ts": "yarn run tsc --clean && yarn run tsc",
"build-ts-cjs": "yarn run tsc resources/tsconfig.build.cjs.json --clean && yarn run tsc resources/tsconfig.build.cjs.json",
"build-ts-esm": "yarn run tsc resources/tsconfig.build.esm.json --clean && yarn run tsc resources/tsconfig.build.esm.json",
Expand All @@ -37,7 +37,9 @@
"test": "jest",
"test-mocha": "yarn workspace codemirror-graphql run test",
"test-all": "yarn test && yarn test-mocha",
"ci": "yarn lint && yarn run check && yarn test && yarn build && yarn test-mocha && yarn build-bundles && yarn e2e && yarn build-validate",
"ci": "yarn lint && yarn run check && yarn build && yarn test",
"ci-e2e": "yarn build-ts-esm && yarn workspace codemirror-graphql run build && yarn workspace graphiql run build-bundles-min && yarn e2e",
"ci-validate": "yarn build-ts-esm && yarn build-validate",
"testonly": "jest && yarn workspace codemirror-graphql run test",
"e2e": "yarn workspace graphiql e2e",
"cypress-open": "yarn workspace graphiql cypress-open",
Expand All @@ -51,7 +53,7 @@
"pretty-check": "node resources/pretty.js --check",
"format": "yarn eslint --fix && yarn pretty",
"lerna-publish": "lerna publish",
"prepublish": "yarn lint && yarn build && yarn build-bundles && yarn test-all && yarn e2e"
"prepublish": "./resources/prepublish.sh"
},
"devDependencies": {
"@babel/cli": "7.7.7",
Expand Down
4 changes: 2 additions & 2 deletions packages/graphql-language-service-server/src/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import { Logger as VSCodeLogger } from 'vscode-jsonrpc';

import fs from 'fs';
import os from 'os';
import * as fs from 'fs';
import * as os from 'os';
import { join } from 'path';

const SEVERITY: { [key: string]: string } = {
Expand Down
24 changes: 12 additions & 12 deletions packages/graphql-language-service-server/src/MessageProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ import { GraphQLLanguageService } from 'graphql-language-service-interface';

import { Range, Position } from 'graphql-language-service-utils';

import { CompletionParams, FileEvent } from 'vscode-languageserver-protocol';
import {
CompletionParams,
FileEvent,
VersionedTextDocumentIdentifier,
DidSaveTextDocumentParams,
DidOpenTextDocumentParams,
} from 'vscode-languageserver-protocol';

import {
Diagnostic,
Expand All @@ -39,8 +45,6 @@ import {
DidChangeWatchedFilesParams,
InitializeParams,
Range as RangeType,
VersionedTextDocumentIdentifier,
DidSaveTextDocumentParams,
TextDocumentPositionParams,
} from 'vscode-languageserver';

Expand Down Expand Up @@ -121,7 +125,7 @@ export class MessageProcessor {
}

async handleDidOpenOrSaveNotification(
params: DidSaveTextDocumentParams,
params: DidSaveTextDocumentParams | DidOpenTextDocumentParams,
): Promise<PublishDiagnosticsParams | null> {
if (!this._isInitialized) {
return null;
Expand All @@ -130,20 +134,18 @@ export class MessageProcessor {
if (!params || !params.textDocument) {
throw new Error('`textDocument` argument is required.');
}

const { text, textDocument } = params;
const { textDocument } = params;
const { uri } = textDocument;

const diagnostics: Diagnostic[] = [];

let contents: CachedContent[] = [];

// Create/modify the cached entry if text is provided.
// Otherwise, try searching the cache to perform diagnostics.
if (text || text === '') {
if ('text' in textDocument && textDocument.text) {
// textDocument/didSave does not pass in the text content.
// Only run the below function if text is passed in.
contents = getQueryAndRange(text, uri);
contents = getQueryAndRange(textDocument.text, uri);
this._invalidateCache(textDocument, uri, contents);
} else {
const cachedDocument = this._getCachedDocument(uri);
Expand Down Expand Up @@ -403,7 +405,7 @@ export class MessageProcessor {

async handleWatchedFilesChangedNotification(
params: DidChangeWatchedFilesParams,
): Promise<PublishDiagnosticsParams[] | null> {
): Promise<Array<PublishDiagnosticsParams | undefined> | null> {
if (!this._isInitialized) {
return null;
}
Expand Down Expand Up @@ -460,9 +462,7 @@ export class MessageProcessor {
change.uri,
false,
);
return { uri: change.uri, diagnostics: [] };
}
return { uri: change.uri, diagnostics: [] };
}),
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/graphiql/resources/prepublish.sh → resources/prepublish.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ if [ "$CI" != true ]; then
exit 1;
fi;

npm run build;
yarn lint && yarn build && yarn build-bundles && yarn test-all && yarn e2e;

0 comments on commit 6b98f8a

Please sign in to comment.