Skip to content

Commit

Permalink
fix(graphql): Allow custom scalars for comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-martin committed Jun 19, 2020
1 parent 88946e2 commit 57cbe38
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,14 @@ const knownTypes: Set<ReturnTypeFuncValue> = new Set([
GraphQLTimestamp,
]);

const isNamed = (Type: any): Type is { name: string } => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
return 'name' in Type && typeof Type.name === 'string';
};

/** @internal */
const getTypeName = <T>(Type: ReturnTypeFuncValue): string => {
if (knownTypes.has(Type) || typeof Type === 'function') {
if (knownTypes.has(Type) || isNamed(Type)) {
const typeName = (Type as { name: string }).name;
return upperCaseFirst(typeName);
}
Expand Down

0 comments on commit 57cbe38

Please sign in to comment.