Skip to content

Commit 4fd6841

Browse files
rmcauleyrmcauley
authored andcommitted
T-257 Allow overriding nameMap in getFormattedFields
1 parent b7bc17e commit 4fd6841

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

index.node.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.web.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/helpers.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export declare type Deep<T> = {
55
1: Deep<T[keyof T]>;
66
}[T extends string ? 0 : 1];
77
export declare function bind<T extends Function>(_target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;
8-
export declare function getFormattedFields(fields?: Array<string>): string;
8+
export declare function getFormattedFields(fields?: Array<string>, nameMap?: Record<string, string>): string;
99
export declare function pageQueryGenerator(name: keyof Query, fields?: Array<string>, hasShowDeleted?: boolean): string;
1010
export interface APIError {
1111
message?: string;

src/helpers.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { codes } from '@adgorithmics/graphql-errors';
22
import { Query } from './generated/graphql';
3-
import { nameMap } from './generated/fields';
3+
import { nameMap as defaultNameMap } from './generated/fields';
44

55
export type Deep<T> = {
66
0: T;
@@ -27,7 +27,10 @@ export function bind<T extends Function>(
2727
};
2828
}
2929

30-
export function getFormattedFields(fields: Array<string> = []) {
30+
export function getFormattedFields(
31+
fields: Array<string> = [],
32+
nameMap: Record<string, string> = defaultNameMap,
33+
) {
3134
return fields
3235
.map(field => {
3336
if (typeof field !== 'string') {

0 commit comments

Comments
 (0)