graphql-language-service-interface
Advanced tools
Comparing version 2.9.4 to 2.9.5-canary-3dcdd158.0
# graphql-language-service-interface | ||
## 2.9.5-canary-3dcdd158.0 | ||
### Patch Changes | ||
- [`38e67621`](https://github.com/graphql/graphiql/commit/38e6762107aeea0e590e841d2c7be2c8eb5025eb) [#2065](https://github.com/graphql/graphiql/pull/2065) Thanks [@acao](https://github.com/acao)! - Add an opt-in feature to generate markdown in hover elements, starting with highlighting type information. Enabled for the language server and also the language service and thus `monaco-graphql` as well. | ||
## 2.9.4 | ||
@@ -4,0 +10,0 @@ |
@@ -5,3 +5,6 @@ import { GraphQLSchema } from 'graphql'; | ||
import { Hover } from 'vscode-languageserver-types'; | ||
export declare function getHoverInformation(schema: GraphQLSchema, queryText: string, cursor: IPosition, contextToken?: ContextToken): Hover['contents']; | ||
export declare type HoverConfig = { | ||
useMarkdown?: boolean; | ||
}; | ||
export declare function getHoverInformation(schema: GraphQLSchema, queryText: string, cursor: IPosition, contextToken?: ContextToken, config?: HoverConfig): Hover['contents']; | ||
//# sourceMappingURL=getHoverInformation.d.ts.map |
@@ -6,3 +6,3 @@ "use strict"; | ||
const getAutocompleteSuggestions_1 = require("./getAutocompleteSuggestions"); | ||
function getHoverInformation(schema, queryText, cursor, contextToken) { | ||
function getHoverInformation(schema, queryText, cursor, contextToken, config) { | ||
const token = contextToken || getAutocompleteSuggestions_1.getTokenAtPosition(queryText, cursor); | ||
@@ -16,7 +16,9 @@ if (!schema || !token || !token.state) { | ||
const typeInfo = getAutocompleteSuggestions_1.getTypeInfo(schema, token.state); | ||
const options = { schema }; | ||
const options = Object.assign(Object.assign({}, config), { schema }); | ||
if ((kind === 'Field' && step === 0 && typeInfo.fieldDef) || | ||
(kind === 'AliasedField' && step === 2 && typeInfo.fieldDef)) { | ||
const into = []; | ||
renderMdCodeStart(into, options); | ||
renderField(into, typeInfo, options); | ||
renderMdCodeEnd(into, options); | ||
renderDescription(into, options, typeInfo.fieldDef); | ||
@@ -27,3 +29,5 @@ return into.join('').trim(); | ||
const into = []; | ||
renderMdCodeStart(into, options); | ||
renderDirective(into, typeInfo, options); | ||
renderMdCodeEnd(into, options); | ||
renderDescription(into, options, typeInfo.directiveDef); | ||
@@ -34,3 +38,5 @@ return into.join('').trim(); | ||
const into = []; | ||
renderMdCodeStart(into, options); | ||
renderArg(into, typeInfo, options); | ||
renderMdCodeEnd(into, options); | ||
renderDescription(into, options, typeInfo.argDef); | ||
@@ -43,3 +49,5 @@ return into.join('').trim(); | ||
const into = []; | ||
renderMdCodeStart(into, options); | ||
renderEnumValue(into, typeInfo, options); | ||
renderMdCodeEnd(into, options); | ||
renderDescription(into, options, typeInfo.enumValue); | ||
@@ -52,3 +60,5 @@ return into.join('').trim(); | ||
const into = []; | ||
renderMdCodeStart(into, options); | ||
renderType(into, typeInfo, options, typeInfo.type); | ||
renderMdCodeEnd(into, options); | ||
renderDescription(into, options, typeInfo.type); | ||
@@ -60,2 +70,12 @@ return into.join('').trim(); | ||
exports.getHoverInformation = getHoverInformation; | ||
function renderMdCodeStart(into, options) { | ||
if (options.useMarkdown) { | ||
text(into, '```graphql\n'); | ||
} | ||
} | ||
function renderMdCodeEnd(into, options) { | ||
if (options.useMarkdown) { | ||
text(into, '\n```'); | ||
} | ||
} | ||
function renderField(into, typeInfo, options) { | ||
@@ -62,0 +82,0 @@ renderQualifiedField(into, typeInfo, options); |
@@ -5,2 +5,3 @@ import { DocumentNode, FragmentSpreadNode, NamedTypeNode } from 'graphql'; | ||
import { Hover, SymbolInformation } from 'vscode-languageserver-types'; | ||
import { HoverConfig } from './getHoverInformation'; | ||
import { DefinitionQueryResult } from './getDefinition'; | ||
@@ -14,3 +15,3 @@ export declare class GraphQLLanguageService { | ||
getAutocompleteSuggestions(query: string, position: IPosition, filePath: Uri): Promise<Array<CompletionItem>>; | ||
getHoverInformation(query: string, position: IPosition, filePath: Uri): Promise<Hover['contents']>; | ||
getHoverInformation(query: string, position: IPosition, filePath: Uri, options?: HoverConfig): Promise<Hover['contents']>; | ||
getDefinition(query: string, position: IPosition, filePath: Uri): Promise<DefinitionQueryResult | null>; | ||
@@ -17,0 +18,0 @@ getDocumentSymbols(document: string, filePath: Uri): Promise<SymbolInformation[]>; |
@@ -136,3 +136,3 @@ "use strict"; | ||
} | ||
getHoverInformation(query, position, filePath) { | ||
getHoverInformation(query, position, filePath, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -142,3 +142,3 @@ const projectConfig = this.getConfigForURI(filePath); | ||
if (schema) { | ||
return getHoverInformation_1.getHoverInformation(schema, query, position); | ||
return getHoverInformation_1.getHoverInformation(schema, query, position, undefined, options); | ||
} | ||
@@ -145,0 +145,0 @@ return ''; |
@@ -5,3 +5,6 @@ import { GraphQLSchema } from 'graphql'; | ||
import { Hover } from 'vscode-languageserver-types'; | ||
export declare function getHoverInformation(schema: GraphQLSchema, queryText: string, cursor: IPosition, contextToken?: ContextToken): Hover['contents']; | ||
export declare type HoverConfig = { | ||
useMarkdown?: boolean; | ||
}; | ||
export declare function getHoverInformation(schema: GraphQLSchema, queryText: string, cursor: IPosition, contextToken?: ContextToken, config?: HoverConfig): Hover['contents']; | ||
//# sourceMappingURL=getHoverInformation.d.ts.map |
import { GraphQLNonNull, GraphQLList, } from 'graphql'; | ||
import { getTokenAtPosition, getTypeInfo } from './getAutocompleteSuggestions'; | ||
export function getHoverInformation(schema, queryText, cursor, contextToken) { | ||
export function getHoverInformation(schema, queryText, cursor, contextToken, config) { | ||
const token = contextToken || getTokenAtPosition(queryText, cursor); | ||
@@ -12,7 +12,9 @@ if (!schema || !token || !token.state) { | ||
const typeInfo = getTypeInfo(schema, token.state); | ||
const options = { schema }; | ||
const options = Object.assign(Object.assign({}, config), { schema }); | ||
if ((kind === 'Field' && step === 0 && typeInfo.fieldDef) || | ||
(kind === 'AliasedField' && step === 2 && typeInfo.fieldDef)) { | ||
const into = []; | ||
renderMdCodeStart(into, options); | ||
renderField(into, typeInfo, options); | ||
renderMdCodeEnd(into, options); | ||
renderDescription(into, options, typeInfo.fieldDef); | ||
@@ -23,3 +25,5 @@ return into.join('').trim(); | ||
const into = []; | ||
renderMdCodeStart(into, options); | ||
renderDirective(into, typeInfo, options); | ||
renderMdCodeEnd(into, options); | ||
renderDescription(into, options, typeInfo.directiveDef); | ||
@@ -30,3 +34,5 @@ return into.join('').trim(); | ||
const into = []; | ||
renderMdCodeStart(into, options); | ||
renderArg(into, typeInfo, options); | ||
renderMdCodeEnd(into, options); | ||
renderDescription(into, options, typeInfo.argDef); | ||
@@ -39,3 +45,5 @@ return into.join('').trim(); | ||
const into = []; | ||
renderMdCodeStart(into, options); | ||
renderEnumValue(into, typeInfo, options); | ||
renderMdCodeEnd(into, options); | ||
renderDescription(into, options, typeInfo.enumValue); | ||
@@ -48,3 +56,5 @@ return into.join('').trim(); | ||
const into = []; | ||
renderMdCodeStart(into, options); | ||
renderType(into, typeInfo, options, typeInfo.type); | ||
renderMdCodeEnd(into, options); | ||
renderDescription(into, options, typeInfo.type); | ||
@@ -55,2 +65,12 @@ return into.join('').trim(); | ||
} | ||
function renderMdCodeStart(into, options) { | ||
if (options.useMarkdown) { | ||
text(into, '```graphql\n'); | ||
} | ||
} | ||
function renderMdCodeEnd(into, options) { | ||
if (options.useMarkdown) { | ||
text(into, '\n```'); | ||
} | ||
} | ||
function renderField(into, typeInfo, options) { | ||
@@ -57,0 +77,0 @@ renderQualifiedField(into, typeInfo, options); |
@@ -5,2 +5,3 @@ import { DocumentNode, FragmentSpreadNode, NamedTypeNode } from 'graphql'; | ||
import { Hover, SymbolInformation } from 'vscode-languageserver-types'; | ||
import { HoverConfig } from './getHoverInformation'; | ||
import { DefinitionQueryResult } from './getDefinition'; | ||
@@ -14,3 +15,3 @@ export declare class GraphQLLanguageService { | ||
getAutocompleteSuggestions(query: string, position: IPosition, filePath: Uri): Promise<Array<CompletionItem>>; | ||
getHoverInformation(query: string, position: IPosition, filePath: Uri): Promise<Hover['contents']>; | ||
getHoverInformation(query: string, position: IPosition, filePath: Uri, options?: HoverConfig): Promise<Hover['contents']>; | ||
getDefinition(query: string, position: IPosition, filePath: Uri): Promise<DefinitionQueryResult | null>; | ||
@@ -17,0 +18,0 @@ getDocumentSymbols(document: string, filePath: Uri): Promise<SymbolInformation[]>; |
@@ -133,3 +133,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
getHoverInformation(query, position, filePath) { | ||
getHoverInformation(query, position, filePath, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -139,3 +139,3 @@ const projectConfig = this.getConfigForURI(filePath); | ||
if (schema) { | ||
return getHoverInformation(schema, query, position); | ||
return getHoverInformation(schema, query, position, undefined, options); | ||
} | ||
@@ -142,0 +142,0 @@ return ''; |
{ | ||
"name": "graphql-language-service-interface", | ||
"version": "2.9.4", | ||
"version": "2.9.5-canary-3dcdd158.0", | ||
"description": "Interface to the GraphQL Language Service", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
@@ -29,2 +29,4 @@ /** | ||
export type HoverConfig = { useMarkdown?: boolean }; | ||
export function getHoverInformation( | ||
@@ -35,2 +37,3 @@ schema: GraphQLSchema, | ||
contextToken?: ContextToken, | ||
config?: HoverConfig, | ||
): Hover['contents'] { | ||
@@ -47,3 +50,3 @@ const token = contextToken || getTokenAtPosition(queryText, cursor); | ||
const typeInfo = getTypeInfo(schema, token.state); | ||
const options = { schema }; | ||
const options = { ...config, schema }; | ||
@@ -58,3 +61,5 @@ // Given a Schema and a Token, produce the contents of an info tooltip. | ||
const into: string[] = []; | ||
renderMdCodeStart(into, options); | ||
renderField(into, typeInfo, options); | ||
renderMdCodeEnd(into, options); | ||
renderDescription(into, options, typeInfo.fieldDef); | ||
@@ -64,3 +69,5 @@ return into.join('').trim(); | ||
const into: string[] = []; | ||
renderMdCodeStart(into, options); | ||
renderDirective(into, typeInfo, options); | ||
renderMdCodeEnd(into, options); | ||
renderDescription(into, options, typeInfo.directiveDef); | ||
@@ -70,3 +77,5 @@ return into.join('').trim(); | ||
const into: string[] = []; | ||
renderMdCodeStart(into, options); | ||
renderArg(into, typeInfo, options); | ||
renderMdCodeEnd(into, options); | ||
renderDescription(into, options, typeInfo.argDef); | ||
@@ -80,3 +89,5 @@ return into.join('').trim(); | ||
const into: string[] = []; | ||
renderMdCodeStart(into, options); | ||
renderEnumValue(into, typeInfo, options); | ||
renderMdCodeEnd(into, options); | ||
renderDescription(into, options, typeInfo.enumValue); | ||
@@ -90,3 +101,5 @@ return into.join('').trim(); | ||
const into: string[] = []; | ||
renderMdCodeStart(into, options); | ||
renderType(into, typeInfo, options, typeInfo.type); | ||
renderMdCodeEnd(into, options); | ||
renderDescription(into, options, typeInfo.type); | ||
@@ -98,2 +111,13 @@ return into.join('').trim(); | ||
function renderMdCodeStart(into: string[], options: any) { | ||
if (options.useMarkdown) { | ||
text(into, '```graphql\n'); | ||
} | ||
} | ||
function renderMdCodeEnd(into: string[], options: any) { | ||
if (options.useMarkdown) { | ||
text(into, '\n```'); | ||
} | ||
} | ||
function renderField(into: string[], typeInfo: AllTypeInfo, options: any) { | ||
@@ -180,2 +204,3 @@ renderQualifiedField(into, typeInfo, options); | ||
} | ||
if (t instanceof GraphQLNonNull) { | ||
@@ -182,0 +207,0 @@ renderType(into, typeInfo, options, t.ofType); |
@@ -38,3 +38,3 @@ /** | ||
import { getAutocompleteSuggestions } from './getAutocompleteSuggestions'; | ||
import { getHoverInformation } from './getHoverInformation'; | ||
import { getHoverInformation, HoverConfig } from './getHoverInformation'; | ||
import { validateQuery, getRange, DIAGNOSTIC_SEVERITY } from './getDiagnostics'; | ||
@@ -254,2 +254,3 @@ import { | ||
filePath: Uri, | ||
options?: HoverConfig, | ||
): Promise<Hover['contents']> { | ||
@@ -260,3 +261,3 @@ const projectConfig = this.getConfigForURI(filePath); | ||
if (schema) { | ||
return getHoverInformation(schema, query, position); | ||
return getHoverInformation(schema, query, position, undefined, options); | ||
} | ||
@@ -263,0 +264,0 @@ return ''; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
398913
6626
2