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

Support code-completing default values for variables #246

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "2.0.0"
"version": "2.0.2"
}
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@
"fetch-mock": "^6.0.0",
"flow-bin": "0.68.0",
"graphql": "^14.0.2",
"graphql-language-service-interface": "^1.0.0-0",
"graphql-language-service-parser": "^0.1.0-0",
"graphql-language-service-server": "^1.0.0-0",
"graphql-language-service-types": "^0.1.0-0",
"graphql-language-service-utils": "^1.0.0-0",
"@apollographql/graphql-language-service-interface": "^1.0.0-0",
"@apollographql/graphql-language-service-parser": "^0.1.0-0",
"@apollographql/graphql-language-service-server": "^1.0.0-0",
"@apollographql/graphql-language-service-types": "^0.1.0-0",
"@apollographql/graphql-language-service-utils": "^1.0.0-0",
"lerna": "^2.0.0",
"mocha": "4.1.0",
"prettier": "1.13"
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-language-server/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "graphql-language-server",
"name": "@apollographql/graphql-language-server",
"version": "1.2.2",
"description": "An interface for building GraphQL language services for IDEs",
"scripts": {
Expand Down
12 changes: 6 additions & 6 deletions packages/graphql-language-service/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphql-language-service",
"repository": "https://github.com/graphql/graphql-language-service",
"name": "@apollographql/graphql-language-service",
"repository": "https://github.com/apollographql/graphql-language-service",
"version": "2.0.0",
"description": "An interface for building GraphQL language services for IDEs",
"contributors": [
Expand Down Expand Up @@ -29,14 +29,14 @@
"prepublish": "node ../../resources/prepublish.js"
},
"peerDependencies": {
"graphql": "^0.6.0 || ^0.7.0 || ^0.8.0-b || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0"
"graphql": "^0.6.0 || ^0.7.0 || ^0.8.0-b || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0"
},
"dependencies": {
"babel-polyfill": "6.16.0",
"graphql-config": "2.0.1",
"graphql-language-service-interface": "^2.0.0",
"graphql-language-service-server": "^2.0.0",
"graphql-language-service-utils": "^2.0.0",
"@apollographql/graphql-language-service-interface": "^2.0.0",
"@apollographql/graphql-language-service-server": "^2.0.0",
"@apollographql/graphql-language-service-utils": "^2.0.0",
"yargs": "^3.32.0 || ^7.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/graphql-language-service/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import yargs from 'yargs';
import client from './client';
import {Logger, startServer} from 'graphql-language-service-server';
import {Logger, startServer} from '@apollographql/graphql-language-service-server';
import watchman from 'fb-watchman';

const {argv} = yargs
Expand Down
4 changes: 2 additions & 2 deletions packages/graphql-language-service/src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import {
getAutocompleteSuggestions,
getDiagnostics,
getOutline,
} from 'graphql-language-service-interface';
import {Position} from 'graphql-language-service-utils';
} from '@apollographql/graphql-language-service-interface';
import {Position} from '@apollographql/graphql-language-service-utils';
import path from 'path';

const GRAPHQL_SUCCESS_CODE = 0;
Expand Down
15 changes: 7 additions & 8 deletions packages/interface/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "graphql-language-service-interface",
"repository": "https://github.com/graphql/graphql-language-service",
"version": "2.0.0",
"name": "@apollographql/graphql-language-service-interface",
"repository": "https://github.com/apollographql/graphql-language-service",
"version": "2.0.2",
"description": "Interface to the GraphQL Language Service",
"contributors": [
"Greg Hurrell <[email protected]> (https://greg.hurrell.net/)",
Expand All @@ -26,12 +26,11 @@
"prepublish": "node ../../resources/prepublish.js"
},
"peerDependencies": {
"graphql": "^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0"
"graphql": "^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0"
},
"dependencies": {
"graphql-config": "2.0.1",
"graphql-language-service-parser": "^1.2.2",
"graphql-language-service-types": "^1.2.2",
"graphql-language-service-utils": "^2.0.0"
"@apollographql/graphql-language-service-parser": "^2.0.0",
"@apollographql/graphql-language-service-types": "^2.0.0",
"@apollographql/graphql-language-service-utils": "^2.0.2"
}
}
6 changes: 3 additions & 3 deletions packages/interface/src/GraphQLLanguageService.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import type {
GraphQLConfig,
GraphQLProjectConfig,
Uri,
} from 'graphql-language-service-types';
import type {Position} from 'graphql-language-service-utils';
} from '@apollographql/graphql-language-service-types';
import type {Position} from '@apollographql/graphql-language-service-utils';
import type {Hover} from 'vscode-languageserver-types';

import {Kind, parse, print} from 'graphql';
Expand All @@ -37,7 +37,7 @@ import {
getDefinitionQueryResultForDefinitionNode,
getDefinitionQueryResultForNamedType,
} from './getDefinition';
import {getASTNodeAtPosition} from 'graphql-language-service-utils';
import {getASTNodeAtPosition} from '@apollographql/graphql-language-service-utils';

const {
FRAGMENT_DEFINITION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
* @flow
*/

import type {CompletionItem} from 'graphql-language-service-types';
import type {CompletionItem} from '@apollographql/graphql-language-service-types';

import {expect} from 'chai';
import {beforeEach, describe, it} from 'mocha';
import fs from 'fs';
import {buildSchema} from 'graphql';
import {Position} from 'graphql-language-service-utils';
import {Position} from '@apollographql/graphql-language-service-utils';
import path from 'path';

import {getAutocompleteSuggestions} from '../getAutocompleteSuggestions';
Expand Down Expand Up @@ -284,4 +284,16 @@ query name {
expect(
testSuggestions('type Type { field(arg: String @', new Position(0, 31)),
).to.deep.equal([{label: 'onAllDefs'}, {label: 'onArg'}]));

it.skip('provides correct suggestions for default variables', () => {
const result = testSuggestions(
'query foo($episode: Episode = ) {',
new Position(0, 30),
);
expect(result).to.deep.equal([
{label: 'EMPIRE', detail: 'Episode'},
{label: 'JEDI', detail: 'Episode'},
{label: 'NEWHOPE', detail: 'Episode'},
]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {expect} from 'chai';
import {beforeEach, describe, it} from 'mocha';
import fs from 'fs';
import {buildSchema} from 'graphql';
import {Position} from 'graphql-language-service-utils';
import {Position} from '@apollographql/graphql-language-service-utils';
import path from 'path';

import {getHoverInformation} from '../getHoverInformation';
Expand Down
2 changes: 1 addition & 1 deletion packages/interface/src/autocompleteUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type {
ContextToken,
State,
TypeInfo,
} from 'graphql-language-service-types';
} from '@apollographql/graphql-language-service-types';

// Utility for returning the state representing the Definition this token state
// is within, if any.
Expand Down
11 changes: 8 additions & 3 deletions packages/interface/src/getAutocompleteSuggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import type {
ContextToken,
State,
TypeInfo,
} from 'graphql-language-service-types';
import type {Position} from 'graphql-language-service-utils';
} from '@apollographql/graphql-language-service-types';
import type {Position} from '@apollographql/graphql-language-service-utils';

import {
GraphQLBoolean,
Expand All @@ -37,7 +37,7 @@ import {
isCompositeType,
isInputType,
} from 'graphql';
import {CharacterStream, onlineParser} from 'graphql-language-service-parser';
import {CharacterStream, onlineParser} from '@apollographql/graphql-language-service-parser';
import {
forEachState,
getDefinitionState,
Expand Down Expand Up @@ -158,6 +158,11 @@ export function getAutocompleteSuggestions(
return getSuggestionsForDirective(token, state, schema);
}

// Default variable values
if (kind === 'DefaultValue') {
return getSuggestionsForInputValues(token, typeInfo);
}

return [];
}

Expand Down
4 changes: 2 additions & 2 deletions packages/interface/src/getDefinition.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import type {
Range,
Uri,
ObjectTypeInfo,
} from 'graphql-language-service-types';
import {locToRange, offsetToPosition} from 'graphql-language-service-utils';
} from '@apollographql/graphql-language-service-types';
import {locToRange, offsetToPosition} from '@apollographql/graphql-language-service-utils';
import invariant from 'assert';

export const LANGUAGE = 'GraphQL';
Expand Down
6 changes: 3 additions & 3 deletions packages/interface/src/getDiagnostics.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ import type {
import type {
Diagnostic,
CustomValidationRule,
} from 'graphql-language-service-types';
} from '@apollographql/graphql-language-service-types';

import invariant from 'assert';
import {findDeprecatedUsages, parse} from 'graphql';
import {CharacterStream, onlineParser} from 'graphql-language-service-parser';
import {CharacterStream, onlineParser} from '@apollographql/graphql-language-service-parser';
import {
Position,
Range,
validateWithCustomRules,
} from 'graphql-language-service-utils';
} from '@apollographql/graphql-language-service-utils';

export const SEVERITY = {
ERROR: 1,
Expand Down
4 changes: 2 additions & 2 deletions packages/interface/src/getHoverInformation.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
*/

import type {GraphQLSchema} from 'graphql';
import type {ContextToken} from 'graphql-language-service-types';
import type {ContextToken} from '@apollographql/graphql-language-service-types';
import type {Hover} from 'vscode-languageserver-types';
import type {Position} from 'graphql-language-service-utils';
import type {Position} from '@apollographql/graphql-language-service-utils';
import {getTokenAtPosition, getTypeInfo} from './getAutocompleteSuggestions';
import {GraphQLNonNull, GraphQLList} from 'graphql';

Expand Down
4 changes: 2 additions & 2 deletions packages/interface/src/getOutline.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import type {
Outline,
TextToken,
TokenKind,
} from 'graphql-language-service-types';
} from '@apollographql/graphql-language-service-types';

import {Kind, parse, visit} from 'graphql';
import {offsetToPosition} from 'graphql-language-service-utils';
import {offsetToPosition} from '@apollographql/graphql-language-service-utils';

const {INLINE_FRAGMENT} = Kind;

Expand Down
11 changes: 5 additions & 6 deletions packages/parser/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "graphql-language-service-parser",
"repository": "https://github.com/graphql/graphql-language-service",
"version": "1.2.2",
"name": "@apollographql/graphql-language-service-parser",
"repository": "https://github.com/apollographql/graphql-language-service",
"version": "2.0.2",
"description": "An online parser for GraphQL for use in syntax-highlighters and code intelligence tools",
"contributors": [
"Greg Hurrell <[email protected]> (https://greg.hurrell.net/)",
Expand All @@ -26,10 +26,9 @@
"prepublish": "node ../../resources/prepublish.js"
},
"peerDependencies": {
"graphql": "^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0"
"graphql": "^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0"
},
"dependencies": {
"graphql-config": "2.0.1",
"graphql-language-service-types": "^1.2.2"
"@apollographql/graphql-language-service-types": "^2.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/parser/src/CharacterStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import type {
TokenPattern,
CharacterStream as CharacterStreamInterface,
} from 'graphql-language-service-types';
} from '@apollographql/graphql-language-service-types';

export default class CharacterStream implements CharacterStreamInterface {
_start: number;
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/src/RuleHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// These functions help build matching rules for ParseRules.

import type {Rule, Token} from 'graphql-language-service-types';
import type {Rule, Token} from '@apollographql/graphql-language-service-types';

// An optional rule.
export function opt(ofRule: Rule | string): Rule {
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/src/Rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
Token,
Rule,
ParseRule,
} from 'graphql-language-service-types';
} from '@apollographql/graphql-language-service-types';
import {opt, list, butNot, t, p} from './RuleHelpers';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/src/onlineParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import type {
CharacterStream,
State,
Token,
} from 'graphql-language-service-types';
} from '@apollographql/graphql-language-service-types';

import {LexRules, ParseRules, isIgnored} from './Rules';

Expand Down
12 changes: 6 additions & 6 deletions packages/server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphql-language-service-server",
"repository": "https://github.com/graphql/graphql-language-service",
"name": "@apollographql/graphql-language-service-server",
"repository": "https://github.com/apollographql/graphql-language-service",
"version": "2.0.0",
"description": "Server process backing the GraphQL Language Service",
"contributors": [
Expand All @@ -26,16 +26,16 @@
"prepublish": "node ../../resources/prepublish.js"
},
"peerDependencies": {
"graphql": "^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0"
"graphql": "^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0"
},
"dependencies": {
"babylon": "^6.17.4",
"fb-watchman": "^2.0.0",
"glob": "^7.1.2",
"graphql-config": "2.0.1",
"graphql-language-service-interface": "^2.0.0",
"graphql-language-service-types": "^1.2.2",
"graphql-language-service-utils": "^2.0.0",
"@apollographql/graphql-language-service-interface": "^2.0.0",
"@apollographql/graphql-language-service-types": "^2.0.0",
"@apollographql/graphql-language-service-utils": "^2.0.0",
"nullthrows": "^1.0.0",
"vscode-jsonrpc": "^3.3.0",
"vscode-languageserver": "^3.3.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/GraphQLCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type {
ObjectTypeInfo,
Uri,
GraphQLProjectConfig,
} from 'graphql-language-service-types';
} from '@apollographql/graphql-language-service-types';

import fs from 'fs';
import path from 'path';
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/GraphQLWatchman.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @flow
*/

import type {Uri} from 'graphql-language-service-types';
import type {Uri} from '@apollographql/graphql-language-service-types';

import watchman from 'fb-watchman';

Expand Down
8 changes: 4 additions & 4 deletions packages/server/src/MessageProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import type {
GraphQLCache,
Range as RangeType,
Uri,
} from 'graphql-language-service-types';
import {FileChangeTypeKind} from 'graphql-language-service-types';
} from '@apollographql/graphql-language-service-types';
import {FileChangeTypeKind} from '@apollographql/graphql-language-service-types';

import {extname, dirname} from 'path';
import {readFileSync} from 'fs';
Expand All @@ -27,8 +27,8 @@ import {
GraphQLProjectConfig,
GraphQLConfig,
} from 'graphql-config';
import {GraphQLLanguageService} from 'graphql-language-service-interface';
import {Position, Range} from 'graphql-language-service-utils';
import {GraphQLLanguageService} from '@apollographql/graphql-language-service-interface';
import {Position, Range} from '@apollographql/graphql-language-service-utils';
import {
CancellationToken,
NotificationMessage,
Expand Down
Loading