Skip to content

Commit

Permalink
test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
david-mcafee committed Dec 12, 2023
1 parent 18fdd10 commit 934d7d4
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions packages/api-graphql/src/internals/InternalGraphQLAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,20 +242,11 @@ export class InternalGraphQLAPIClass {

const authMode = explicitAuthMode || defaultAuthMode || 'iam';

const endpoint = customEndpoint || appSyncGraphqlEndpoint;
const rqendpoint = customEndpoint || appSyncGraphqlEndpoint;

if (!endpoint) {
const error = new GraphQLError('No graphql endpoint provided.');
const rqurl = new AmplifyUrl(rqendpoint);

throw {
data: {},
errors: [error],
};
}

const url = new AmplifyUrl(endpoint);

const queryString = print(query as DocumentNode);
const rqqueryString = print(query as DocumentNode);

/**
* Retrieve library options from Amplify configuration.
Expand All @@ -277,8 +268,8 @@ export class InternalGraphQLAPIClass {
if (typeof additionalHeaders === 'function') {
const requestOptions: RequestOptions = {
method: 'POST',
url: url.toString(),
queryString,
url: rqurl.toString(),
queryString: rqqueryString,
};

additionalCustomHeaders = await additionalHeaders(requestOptions);
Expand Down Expand Up @@ -332,7 +323,7 @@ export class InternalGraphQLAPIClass {
};

const body = {
query: queryString,
query: print(query as DocumentNode),
variables: variables || null,
};

Expand Down Expand Up @@ -360,11 +351,22 @@ export class InternalGraphQLAPIClass {
};
}

const endpoint = customEndpoint || appSyncGraphqlEndpoint;

if (!endpoint) {
const error = new GraphQLError('No graphql endpoint provided.');

throw {
data: {},
errors: [error],
};
}

let response: any;

try {
const { body: responseBody } = await this._api.post({
url,
url: new AmplifyUrl(endpoint),
options: {
headers,
body,
Expand Down

0 comments on commit 934d7d4

Please sign in to comment.