Skip to content

Commit

Permalink
chore: publish 5.2.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Sep 10, 2018
1 parent 75dbd12 commit 5f73dd8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -14,6 +14,7 @@ npm-debug.log
/test
/coverage
/.nyc_output
test-schema.graphql

# dist
/dist
19 changes: 13 additions & 6 deletions lib/services/scalars-explorer.service.ts
Expand Up @@ -26,19 +26,26 @@ export class ScalarsExplorerService extends BaseExplorerService {
return this.flatMap<any>(modules, instance => this.filterScalar(instance));
}

filterScalar(instance: Object) {
filterScalar<T extends any = any>(instance: T) {
if (!instance) {
return undefined;
}
const customScalarName = Reflect.getMetadata(
const name = Reflect.getMetadata(
SCALAR_NAME_METADATA,
instance.constructor,
);
return customScalarName
const bindContext = (fn: Function | undefined) =>
fn ? fn.bind(instance) : undefined;

return name
? {
[customScalarName]: new GraphQLScalarType(
Object.assign<any, any>(instance, { name: customScalarName }),
),
[name]: new GraphQLScalarType({
name,
description: instance['description'],
parseValue: bindContext(instance.parseValue),
serialize: bindContext(instance.serialize),
parseLiteral: bindContext(instance.parseLiteral),
}),
}
: undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@nestjs/graphql",
"version": "5.2.0",
"version": "5.2.1",
"description":
"Nest - modern, fast, powerful node.js web framework (@graphql)",
"author": "Kamil Mysliwiec",
Expand Down

0 comments on commit 5f73dd8

Please sign in to comment.