Skip to content

Commit

Permalink
add 'withCredentials' to 'core' config; pass 'withCredentials' to int…
Browse files Browse the repository at this point in the history
…ernal REST API 'post'
  • Loading branch information
david-mcafee committed Oct 6, 2023
1 parent 04a5224 commit bdf1256
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/api-graphql/src/internals/InternalGraphQLAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ export class InternalGraphQLAPIClass {
} = resolveConfig(amplify);

// Retrieve library options from Amplify configuration
const { headers: customHeaders } = resolveLibraryOptions(amplify);
const { headers: customHeaders, withCredentials } =
resolveLibraryOptions(amplify);

let customHeadersOptions;

Expand Down Expand Up @@ -309,6 +310,7 @@ export class InternalGraphQLAPIClass {
headers,
body,
signingServiceInfo,
withCredentials,
},
abortController,
});
Expand Down
4 changes: 2 additions & 2 deletions packages/api-graphql/src/utils/resolveLibraryOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import { AmplifyClassV6 } from '@aws-amplify/core';
* @internal
*/
export const resolveLibraryOptions = (amplify: AmplifyClassV6) => {
const headers = amplify.libraryOptions?.API?.GraphQL?.headers;
return { headers };
const { headers, withCredentials } = amplify.libraryOptions?.API?.GraphQL;
return { headers, withCredentials };
};
1 change: 1 addition & 0 deletions packages/core/src/singleton/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type LibraryAPIOptions = {
query: string;
variables?: Record<string, DocumentType>;
}) => Promise<Headers>;
withCredentials: boolean;
};
REST?: {
// custom headers for given REST service. Will be applied to all operations.
Expand Down

0 comments on commit bdf1256

Please sign in to comment.