Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaMachina committed Mar 31, 2023
1 parent 0ab7426 commit 539dbdf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ module.exports = {
'sort-imports': 0,
'symbol-description': 1,

'sonarjs/no-ignored-return': 'error',
'unicorn/no-array-push-push': 'error',
'import/no-extraneous-dependencies': 'error',
'import/no-duplicates': 'error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,12 @@ export const getUtils = (source: string) => {
};

export const performForEachType = (source, test) => {
Object.keys(typesMap).map(type => {
const { value, kind, valueType } = typesMap[type];
for (const [type, { value, kind, valueType }] of Object.entries(typesMap)) {
const utils = getUtils(
source.replaceAll('__VALUE__', value).replaceAll('__TYPE__', type),
);
test(utils, { type, value, kind, valueType });
});
}
};

export const expectVarsDef = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ const scalarTypesMap: { [key: string]: JSONSchema6TypeName } = {

class Marker {
private set = new Set<string>();

mark(name: string): boolean {
if (this.set.has(name)) {
return false;
Expand Down Expand Up @@ -238,9 +239,9 @@ function getJSONSchemaFromGraphQLType(
fieldDef.required!.push(fieldName);
}
if (typeDefinitions) {
Object.keys(typeDefinitions).map(defName => {
definitions[defName] = typeDefinitions[defName];
});
for (const [defName, value] of Object.entries(typeDefinitions)) {
definitions[defName] = value;
}
}
});
definitions[type.name] = fieldDef;
Expand Down Expand Up @@ -269,6 +270,7 @@ function getJSONSchemaFromGraphQLType(

return { required, definition, definitions };
}

/**
* Generates a JSONSchema6 valid document for operation(s) from a map of Map<string, GraphQLInputType>.
*
Expand Down
10 changes: 8 additions & 2 deletions packages/vscode-graphql-execution/src/providers/exec-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,22 @@ export class GraphQLContentProvider implements TextDocumentContentProvider {
this.html = err.toString();
});
}

validUrlFromSchema(pathOrUrl: string) {
return /^https?:\/\//.test(pathOrUrl);
}

reportError(message: string) {
this.outputChannel.appendLine(message);
this.setContentAndUpdate(message);
}

setContentAndUpdate(html: string) {
this.html = html;
this.update(this.uri);
this.updatePanel();
}

async loadEndpoint(
projectConfig?: GraphQLProjectConfig,
): Promise<Endpoint | null> {
Expand All @@ -144,11 +148,11 @@ export class GraphQLContentProvider implements TextDocumentContentProvider {
);
const { schema } = projectConfig;
if (schema && Array.isArray(schema)) {
schema.map(s => {
for (const s of schema) {
if (this.validUrlFromSchema(s as string)) {
endpoints.default.url = s.toString();
}
});
}
} else if (schema && this.validUrlFromSchema(schema as string)) {
endpoints.default.url = schema.toString();
}
Expand All @@ -174,6 +178,7 @@ export class GraphQLContentProvider implements TextDocumentContentProvider {
const endpointName = await this.getEndpointName(endpointNames);
return endpoints[endpointName] || endpoints.default;
}

async loadProvider() {
try {
const rootDir = workspace.getWorkspaceFolder(Uri.file(this.literal.uri));
Expand Down Expand Up @@ -240,6 +245,7 @@ export class GraphQLContentProvider implements TextDocumentContentProvider {
return;
}
}

async loadConfig() {
const { rootDir, literal } = this;
if (!rootDir) {
Expand Down

0 comments on commit 539dbdf

Please sign in to comment.