Skip to content

Commit

Permalink
fix default values in doc viewer type.
Browse files Browse the repository at this point in the history
  • Loading branch information
Migushthe2nd committed Sep 29, 2021
1 parent 2cc2662 commit 344acb3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Expand Up @@ -73,7 +73,7 @@
(click)="goToType(arg.type.inspect())"
>
{{ arg.name }}
<span class="doc-viewer-item-value" *ngIf="arg.defaultValue && arg.defaultValue.toString">= {{ arg.defaultValue }}</span>
<span class="doc-viewer-item-value" *ngIf="getDefaultValue(arg)">= {{ getDefaultValue(arg) }}</span>
</span>
<span
class="doc-viewer-item-type no-link-link"
Expand Down
Expand Up @@ -5,7 +5,7 @@ import {
EventEmitter,
ChangeDetectionStrategy
} from '@angular/core';
import { GraphQLInterfaceType, GraphQLObjectType, GraphQLSchema, GraphQLType, GraphQLAbstractType } from 'graphql';
import { GraphQLInterfaceType, GraphQLObjectType, GraphQLSchema, GraphQLType, GraphQLAbstractType, GraphQLArgument } from 'graphql';

@Component({
selector: 'app-doc-viewer-type',
Expand Down Expand Up @@ -87,4 +87,11 @@ export class DocViewerTypeComponent {
schemaItemTrackBy(index: number, schemaItem: any) {
return schemaItem.name;
}

getDefaultValue(arg: GraphQLArgument) {
if (typeof arg.defaultValue !== 'undefined') {
return JSON.stringify(arg.defaultValue);
}
return;
}
}

0 comments on commit 344acb3

Please sign in to comment.