Skip to content

Fix reject on introspection failure #190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions dist/vuex-orm-graphql.cjs.js
Original file line number Diff line number Diff line change
@@ -14853,10 +14853,11 @@ var Context = /** @class */ (function () {
return __generator(this, function (_a) {
if (!this.schemaWillBeLoaded) {
this.schemaWillBeLoaded = new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
var context, result;
var context, result, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
this.logger.log("Fetching GraphQL Schema initially ...");
this.connectionMode = this.adapter.getConnectionMode();
context = {
@@ -14871,7 +14872,12 @@ var Context = /** @class */ (function () {
this.processSchema();
this.logger.log("Schema procession done!");
resolve(this.schema);
return [2 /*return*/];
return [3 /*break*/, 3];
case 2:
e_1 = _a.sent();
reject(e_1);
return [3 /*break*/, 3];
case 3: return [2 /*return*/];
}
});
}); });
31 changes: 18 additions & 13 deletions dist/vuex-orm-graphql.esm-bundler.js
Original file line number Diff line number Diff line change
@@ -14866,19 +14866,24 @@ class Context {
async loadSchema() {
if (!this.schemaWillBeLoaded) {
this.schemaWillBeLoaded = new Promise(async (resolve, reject) => {
this.logger.log("Fetching GraphQL Schema initially ...");
this.connectionMode = this.adapter.getConnectionMode();
// We send a custom header along with the request. This is required for our test suite to mock the schema request.
const context = {
headers: { "X-GraphQL-Introspection-Query": "true" }
};
const result = await this.apollo.simpleQuery(introspectionQuery, {}, true, context);
this.schema = new Schema(result.data.__schema);
this.logger.log("GraphQL Schema successful fetched", result);
this.logger.log("Starting to process the schema ...");
this.processSchema();
this.logger.log("Schema procession done!");
resolve(this.schema);
try {
this.logger.log("Fetching GraphQL Schema initially ...");
this.connectionMode = this.adapter.getConnectionMode();
// We send a custom header along with the request. This is required for our test suite to mock the schema request.
const context = {
headers: { "X-GraphQL-Introspection-Query": "true" }
};
const result = await this.apollo.simpleQuery(introspectionQuery, {}, true, context);
this.schema = new Schema(result.data.__schema);
this.logger.log("GraphQL Schema successful fetched", result);
this.logger.log("Starting to process the schema ...");
this.processSchema();
this.logger.log("Schema procession done!");
resolve(this.schema);
}
catch (e) {
reject(e);
}
});
}
return this.schemaWillBeLoaded;
31 changes: 18 additions & 13 deletions dist/vuex-orm-graphql.esm.js
Original file line number Diff line number Diff line change
@@ -14866,19 +14866,24 @@ class Context {
async loadSchema() {
if (!this.schemaWillBeLoaded) {
this.schemaWillBeLoaded = new Promise(async (resolve, reject) => {
this.logger.log("Fetching GraphQL Schema initially ...");
this.connectionMode = this.adapter.getConnectionMode();
// We send a custom header along with the request. This is required for our test suite to mock the schema request.
const context = {
headers: { "X-GraphQL-Introspection-Query": "true" }
};
const result = await this.apollo.simpleQuery(introspectionQuery, {}, true, context);
this.schema = new Schema(result.data.__schema);
this.logger.log("GraphQL Schema successful fetched", result);
this.logger.log("Starting to process the schema ...");
this.processSchema();
this.logger.log("Schema procession done!");
resolve(this.schema);
try {
this.logger.log("Fetching GraphQL Schema initially ...");
this.connectionMode = this.adapter.getConnectionMode();
// We send a custom header along with the request. This is required for our test suite to mock the schema request.
const context = {
headers: { "X-GraphQL-Introspection-Query": "true" }
};
const result = await this.apollo.simpleQuery(introspectionQuery, {}, true, context);
this.schema = new Schema(result.data.__schema);
this.logger.log("GraphQL Schema successful fetched", result);
this.logger.log("Starting to process the schema ...");
this.processSchema();
this.logger.log("Schema procession done!");
resolve(this.schema);
}
catch (e) {
reject(e);
}
});
}
return this.schemaWillBeLoaded;
31 changes: 18 additions & 13 deletions dist/vuex-orm-graphql.esm.prod.js
Original file line number Diff line number Diff line change
@@ -14866,19 +14866,24 @@ class Context {
async loadSchema() {
if (!this.schemaWillBeLoaded) {
this.schemaWillBeLoaded = new Promise(async (resolve, reject) => {
this.logger.log("Fetching GraphQL Schema initially ...");
this.connectionMode = this.adapter.getConnectionMode();
// We send a custom header along with the request. This is required for our test suite to mock the schema request.
const context = {
headers: { "X-GraphQL-Introspection-Query": "true" }
};
const result = await this.apollo.simpleQuery(introspectionQuery, {}, true, context);
this.schema = new Schema(result.data.__schema);
this.logger.log("GraphQL Schema successful fetched", result);
this.logger.log("Starting to process the schema ...");
this.processSchema();
this.logger.log("Schema procession done!");
resolve(this.schema);
try {
this.logger.log("Fetching GraphQL Schema initially ...");
this.connectionMode = this.adapter.getConnectionMode();
// We send a custom header along with the request. This is required for our test suite to mock the schema request.
const context = {
headers: { "X-GraphQL-Introspection-Query": "true" }
};
const result = await this.apollo.simpleQuery(introspectionQuery, {}, true, context);
this.schema = new Schema(result.data.__schema);
this.logger.log("GraphQL Schema successful fetched", result);
this.logger.log("Starting to process the schema ...");
this.processSchema();
this.logger.log("Schema procession done!");
resolve(this.schema);
}
catch (e) {
reject(e);
}
});
}
return this.schemaWillBeLoaded;
10 changes: 8 additions & 2 deletions dist/vuex-orm-graphql.global.js
Original file line number Diff line number Diff line change
@@ -14852,10 +14852,11 @@ var VuexORMGraphQLPlugin = (function (exports) {
return __generator(this, function (_a) {
if (!this.schemaWillBeLoaded) {
this.schemaWillBeLoaded = new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
var context, result;
var context, result, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
this.logger.log("Fetching GraphQL Schema initially ...");
this.connectionMode = this.adapter.getConnectionMode();
context = {
@@ -14870,7 +14871,12 @@ var VuexORMGraphQLPlugin = (function (exports) {
this.processSchema();
this.logger.log("Schema procession done!");
resolve(this.schema);
return [2 /*return*/];
return [3 /*break*/, 3];
case 2:
e_1 = _a.sent();
reject(e_1);
return [3 /*break*/, 3];
case 3: return [2 /*return*/];
}
});
}); });
2 changes: 1 addition & 1 deletion dist/vuex-orm-graphql.global.prod.js

Large diffs are not rendered by default.

40 changes: 22 additions & 18 deletions src/common/context.ts
Original file line number Diff line number Diff line change
@@ -150,31 +150,35 @@ export default class Context {
public async loadSchema(): Promise<Schema> {
if (!this.schemaWillBeLoaded) {
this.schemaWillBeLoaded = new Promise(async (resolve, reject) => {
this.logger.log("Fetching GraphQL Schema initially ...");
try {
this.logger.log("Fetching GraphQL Schema initially ...");

this.connectionMode = this.adapter.getConnectionMode();
this.connectionMode = this.adapter.getConnectionMode();

// We send a custom header along with the request. This is required for our test suite to mock the schema request.
const context = {
headers: { "X-GraphQL-Introspection-Query": "true" }
};
// We send a custom header along with the request. This is required for our test suite to mock the schema request.
const context = {
headers: { "X-GraphQL-Introspection-Query": "true" }
};

const result = await this.apollo.simpleQuery(
introspectionQuery,
{},
true,
(context as unknown) as Data
);
const result = await this.apollo.simpleQuery(
introspectionQuery,
{},
true,
(context as unknown) as Data
);

this.schema = new Schema(result.data.__schema);
this.schema = new Schema(result.data.__schema);

this.logger.log("GraphQL Schema successful fetched", result);
this.logger.log("GraphQL Schema successful fetched", result);

this.logger.log("Starting to process the schema ...");
this.processSchema();
this.logger.log("Schema procession done!");
this.logger.log("Starting to process the schema ...");
this.processSchema();
this.logger.log("Schema procession done!");

resolve(this.schema);
resolve(this.schema);
} catch (e) {
reject(e);
}
});
}