Skip to content

Commit

Permalink
update naming
Browse files Browse the repository at this point in the history
  • Loading branch information
david-mcafee committed Dec 1, 2023
1 parent c25e27b commit 8ef0f54
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1065,11 +1065,11 @@ describe('AWSAppSyncRealTimeProvider', () => {
/**
* When Amplify is configured with a `header` function
* that returns an `Authorization` token, the GraphQL
* API will pass this function as the `libraryOptionsHeaders`
* API will pass this function as the `libraryConfigHeaders`
* option to the AWSAppSyncRealTimeProvider's `subscribe`
* function.
*/
libraryOptionsHeaders: async () => ({
libraryConfigHeaders: async () => ({
Authorization: 'test',
}),
})
Expand Down
8 changes: 4 additions & 4 deletions packages/api-graphql/__tests__/generateClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
expectSub,
expectSubWithHeaders,
expectSubWithHeadersFn,
expectSubWithLibraryOptionsHeaders,
expectSubWithlibraryConfigHeaders,
} from './utils/expects';
import { Observable, from } from 'rxjs';
import * as internals from '../src/internals/';
Expand Down Expand Up @@ -5353,7 +5353,7 @@ describe('generateClient', () => {
}).subscribe({
next(value) {
// This util checks for the existence of library config headers:
expectSubWithLibraryOptionsHeaders(
expectSubWithlibraryConfigHeaders(
spy,
'onCreateNote',
graphqlVariables,
Expand Down Expand Up @@ -5403,7 +5403,7 @@ describe('generateClient', () => {
}).subscribe({
next(value) {
// This util checks for the existence of library config headers:
expectSubWithLibraryOptionsHeaders(
expectSubWithlibraryConfigHeaders(
spy,
'onUpdateNote',
graphqlVariables,
Expand Down Expand Up @@ -5453,7 +5453,7 @@ describe('generateClient', () => {
}).subscribe({
next(value) {
// This util checks for the existence of library config headers:
expectSubWithLibraryOptionsHeaders(
expectSubWithlibraryConfigHeaders(
spy,
'onDeleteNote',
graphqlVariables,
Expand Down
6 changes: 3 additions & 3 deletions packages/api-graphql/__tests__/utils/expects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ export function expectSubWithHeadersFn(
* @param spy The jest spy to check.
* @param opName The name of the graphql operation. E.g., `onCreateTodo`.
* @param item The item we expect to have been in the `variables`
* @param libraryOptionsHeaders TODO
* @param libraryConfigHeaders TODO
*/
export function expectSubWithLibraryOptionsHeaders(
export function expectSubWithlibraryConfigHeaders(
spy: jest.SpyInstance<any, any>,
opName: string,
item: Record<string, any>,
Expand All @@ -203,7 +203,7 @@ export function expectSubWithLibraryOptionsHeaders(
variables: expect.objectContaining(item),
additionalHeaders: expect.objectContaining(headers),
// `headers` that are included in `Amplify.configure` options
libraryOptionsHeaders: expect.any(Function),
libraryConfigHeaders: expect.any(Function),
}),
{
action: '1',
Expand Down
2 changes: 1 addition & 1 deletion packages/api-graphql/src/GraphQLAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class GraphQLAPIClass extends InternalGraphQLAPIClass {
* Executes a GraphQL operation
*
* @param options - GraphQL Options
* @param [additionalHeaders] - headers to merge in after any `libraryOptionsHeaders` set in the config
* @param [additionalHeaders] - headers to merge in after any `libraryConfigHeaders` set in the config
* @returns An Observable if the query is a subscription query, else a promise of the graphql result.
*/
graphql<T = any>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export interface AWSAppSyncRealTimeProviderOptions {
variables?: Record<string, DocumentType>;
apiKey?: string;
region?: string;
libraryOptionsHeaders?: () => {} | (() => Promise<{}>);
libraryConfigHeaders?: () => {} | (() => Promise<{}>);
additionalHeaders?:
| Record<string, string>
| (() => Promise<Record<string, string>>);
Expand Down Expand Up @@ -203,7 +203,7 @@ export class AWSAppSyncRealTimeProvider {
additionalHeaders,
apiKey,
authToken,
libraryOptionsHeaders,
libraryConfigHeaders,
} = options || {};

return new Observable(observer => {
Expand Down Expand Up @@ -236,7 +236,7 @@ export class AWSAppSyncRealTimeProvider {
additionalHeaders,
apiKey,
authToken,
libraryOptionsHeaders,
libraryConfigHeaders,
},
observer,
subscriptionId,
Expand Down Expand Up @@ -315,7 +315,7 @@ export class AWSAppSyncRealTimeProvider {
variables,
apiKey,
region,
libraryOptionsHeaders = () => ({}),
libraryConfigHeaders = () => ({}),
additionalHeaders = {},
authToken,
} = options;
Expand Down Expand Up @@ -363,7 +363,7 @@ export class AWSAppSyncRealTimeProvider {
region,
additionalCustomHeaders,
})),
...(await libraryOptionsHeaders()),
...(await libraryConfigHeaders()),
...additionalCustomHeaders,
[USER_AGENT_HEADER]: getAmplifyUserAgent(customUserAgentDetails),
};
Expand Down
10 changes: 5 additions & 5 deletions packages/api-graphql/src/internals/InternalGraphQLAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class InternalGraphQLAPIClass {
* Executes a GraphQL operation
*
* @param options - GraphQL Options
* @param [additionalHeaders] - headers to merge in after any `libraryOptionsHeaders` set in the config
* @param [additionalHeaders] - headers to merge in after any `libraryConfigHeaders` set in the config
* @returns An Observable if the query is a subscription query, else a promise of the graphql result.
*/
graphql<T = any>(
Expand Down Expand Up @@ -426,13 +426,13 @@ export class InternalGraphQLAPIClass {

/**
* Retrieve library options from Amplify configuration.
* `libraryOptionsHeaders` are from the Amplify configuration options,
* `libraryConfigHeaders` are from the Amplify configuration options,
* and will not be overwritten by other custom headers. These are *not*
* the same as `additionalHeaders`, which are custom headers that are
* the same as `additionalHeaders`, which are custom headers that are
* either 1)included when configuring the API client or 2) passed along
* with individual requests.
*/
const { headers: libraryOptionsHeaders } = resolveLibraryOptions(amplify);
const { headers: libraryConfigHeaders } = resolveLibraryOptions(amplify);

return this.appSyncRealTime.subscribe(
{
Expand All @@ -444,7 +444,7 @@ export class InternalGraphQLAPIClass {
apiKey: config?.apiKey,
additionalHeaders,
authToken,
libraryOptionsHeaders,
libraryConfigHeaders,
},
customUserAgentDetails
);
Expand Down
2 changes: 1 addition & 1 deletion packages/api-graphql/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export interface AWSAppSyncRealTimeProviderOptions {
variables?: Record<string, unknown>;
apiKey?: string;
region?: string;
libraryOptionsHeaders?: () => {} | (() => Promise<{}>);
libraryConfigHeaders?: () => {} | (() => Promise<{}>);
additionalHeaders?: CustomHeaders;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/api-rest/src/apis/common/publicApis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ const publicHandler = (
apiPath,
apiOptions?.queryParams
);
const libraryOptionsHeaders =
const libraryConfigHeaders =
await amplify.libraryOptions?.API?.REST?.headers?.({
apiName,
});
const { headers: invocationHeaders = {} } = apiOptions;
const headers = {
// custom headers from invocation options should precede library options
...libraryOptionsHeaders,
...libraryConfigHeaders,
...invocationHeaders,
};
const signingServiceInfo = parseSigningInfo(url, {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/internals/InternalAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class InternalAPIClass {
* Executes a GraphQL operation
*
* @param options - GraphQL Options
* @param [additionalHeaders] - headers to merge in after any `libraryOptionsHeaders` set in the config
* @param [additionalHeaders] - headers to merge in after any `libraryConfigHeaders` set in the config
* @returns An Observable if queryType is 'subscription', else a promise of the graphql result from the query.
*/
graphql<T>(
Expand Down

0 comments on commit 8ef0f54

Please sign in to comment.