Skip to content

Commit

Permalink
feat: hide deprecated doc items (queries, mutations, fields...)
Browse files Browse the repository at this point in the history
  • Loading branch information
JOSU9435 authored and imolorhe committed Jun 23, 2024
1 parent 1660117 commit 50adf9f
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
[data]="gqlSchema.getType(cleanName(data.type.inspect()))"
[gqlSchema]="gqlSchema"
[sortByOption]="sortByOption"
[hideDeprecatedDocItems]="hideDeprecatedDocItems"
(goToFieldChange)="goToField($event.name, $event.parentType)"
(goToTypeChange)="goToType($event.name)"
(addToEditorChange)="addToEditor($event)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export class DocViewerFieldComponent {
@Input() gqlSchema?: GraphQLSchema;
@Input() parentType = '';
@Input() sortByOption: SortByOptions = 'none';
@Input() hideDeprecatedDocItems: boolean = false;

@Output() goToFieldChange = new EventEmitter();
@Output() goToTypeChange = new EventEmitter();
@Output() addToEditorChange = new EventEmitter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,26 @@
{{ 'DOCS_VALUES_TEXT' | translate }}
</div>
@for (item of getTypeEnumValues(data); track schemaItemTrackBy($index, item)) {
<div class="doc-viewer-item doc-viewer-item-query">
<div class="doc-viewer-item-query-inner">
<span class="doc-viewer-item-field doc-viewer-item-value">
{{ item.name }}
</span>
<span class="doc-viewer-item-type">
{{ item.value }}
</span>
<app-doc-viewer-deprecated [item]="item"></app-doc-viewer-deprecated>
@if (!(hideDeprecatedDocItems && item?.isDeprecated)) {
<div class="doc-viewer-item doc-viewer-item-query">
<div class="doc-viewer-item-query-inner">
<span class="doc-viewer-item-field doc-viewer-item-value">
{{ item.name }}
</span>
<span class="doc-viewer-item-type">
{{ item.value }}
</span>
<app-doc-viewer-deprecated [item]="item"></app-doc-viewer-deprecated>
</div>
@if (item.description) {
<div
class="doc-viewer-item-query-description"
markdown
[data]="item.description || ''"
></div>
}
</div>
@if (item.description) {
<div
class="doc-viewer-item-query-description"
markdown
[data]="item.description || ''"
></div>
}
</div>
}
}
</div>
}
Expand Down Expand Up @@ -124,72 +126,74 @@
| collectionTransform: sortFieldsTransformer : sortByOption;
track schemaItemTrackBy($index, item)
) {
<div class="doc-viewer-item doc-viewer-item-query">
<div class="doc-viewer-item-query-inner">
<span
class="no-link-link"
(click)="goToField(item.name, data.name)"
track-id="gotofield_docs"
>
{{ item.name }}
</span>
@if (item?.args?.length) {
(
@for (
arg of item.args;
track schemaItemTrackBy($index, arg);
let last = $last
) {
<span>
<span
class="doc-viewer-item-field no-link-link"
(click)="goToType(arg.type.inspect())"
>
{{ arg.name }}
@if (getDefaultValue(arg)) {
<span class="doc-viewer-item-value"
>= {{ getDefaultValue(arg) }}</span
>
@if (!(hideDeprecatedDocItems && item?.isDeprecated)) {
<div class="doc-viewer-item doc-viewer-item-query">
<div class="doc-viewer-item-query-inner">
<span
class="no-link-link"
(click)="goToField(item.name, data.name)"
track-id="gotofield_docs"
>
{{ item.name }}
</span>
@if (item?.args?.length) {
(
@for (
arg of item.args;
track schemaItemTrackBy($index, arg);
let last = $last
) {
<span>
<span
class="doc-viewer-item-field no-link-link"
(click)="goToType(arg.type.inspect())"
>
{{ arg.name }}
@if (getDefaultValue(arg)) {
<span class="doc-viewer-item-value"
>= {{ getDefaultValue(arg) }}</span
>
}
</span>
<span
class="doc-viewer-item-type no-link-link"
(click)="goToType(arg.type.inspect())"
>{{ arg.type.inspect() }}</span
>
@if (!last) {
<span>,</span>
}
</span>
<span
class="doc-viewer-item-type no-link-link"
(click)="goToType(arg.type.inspect())"
>{{ arg.type.inspect() }}</span
>
@if (!last) {
<span>,</span>
}
</span>
}
)
}
)
}
<span
class="doc-viewer-item-type doc-viewer-item-query-type no-link-link"
(click)="goToType(item.type.inspect())"
<span
class="doc-viewer-item-type doc-viewer-item-query-type no-link-link"
(click)="goToType(item.type.inspect())"
>
{{ item.type.inspect() }}
</span>
</div>
<app-doc-viewer-deprecated [item]="item"></app-doc-viewer-deprecated>
<div
class="doc-viewer-item-query-description"
markdown
[data]="item.description || ''"
></div>
<button
class="doc-viewer-item-query-add-btn"
(click)="addToEditor(item.name, data.name)"
track-id="add_query"
>
{{ item.type.inspect() }}
</span>
@if (isRootType(data.name)) {
{{ 'DOCS_ADD_QUERY_TEXT' | translate }}
}
@if (!isRootType(data.name)) {
{{ 'DOCS_ADD_FRAGMENT_TEXT' | translate }}
}
</button>
</div>
<app-doc-viewer-deprecated [item]="item"></app-doc-viewer-deprecated>
<div
class="doc-viewer-item-query-description"
markdown
[data]="item.description || ''"
></div>
<button
class="doc-viewer-item-query-add-btn"
(click)="addToEditor(item.name, data.name)"
track-id="add_query"
>
@if (isRootType(data.name)) {
{{ 'DOCS_ADD_QUERY_TEXT' | translate }}
}
@if (!isRootType(data.name)) {
{{ 'DOCS_ADD_FRAGMENT_TEXT' | translate }}
}
</button>
</div>
}
}
</div>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export class DocViewerTypeComponent {
@Input() data?: GraphQLNamedType | null;
@Input() gqlSchema?: GraphQLSchema;
@Input() sortByOption: SortByOptions = 'none';
@Input() hideDeprecatedDocItems: boolean = false;

@Output() goToFieldChange = new EventEmitter();
@Output() goToTypeChange = new EventEmitter();
@Output() addToEditorChange = new EventEmitter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
[data]="gqlSchema.getType(docView.name)"
[gqlSchema]="gqlSchema"
[sortByOption]="sortFieldsByOption"
[hideDeprecatedDocItems]="hideDeprecatedDocItems"
(goToFieldChange)="goToField($event.name, $event.parentType)"
(goToTypeChange)="goToType($event.name)"
(addToEditorChange)="addToEditor($event.name, $event.parentType)"
Expand All @@ -123,12 +124,13 @@
}
}
@case ('field') {
@if (docView.view === 'field') {
@if (!(hideDeprecatedDocItems && getField(docView)?.isDeprecated) && docView.view === 'field') {
<app-doc-viewer-field
[data]="getField(docView)"
[gqlSchema]="gqlSchema"
[parentType]="docView.parentType"
[sortByOption]="sortFieldsByOption"
[hideDeprecatedDocItems]="hideDeprecatedDocItems"
(goToFieldChange)="goToField($event.name, $event.parentType)"
(goToTypeChange)="goToType($event.name)"
(addToEditorChange)="addToEditor($event.name, $event.parentType)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { debounce } from 'lodash-es';
export class DocViewerComponent implements OnChanges {
@Input() gqlSchema?: GraphQLSchema;
@Input() allowIntrospection = true;
@Input() hideDeprecatedDocItems = false;
@Input() isLoading = false;
@Input() addQueryDepthLimit = this.altairConfig.add_query_depth_limit;
@Input() tabSize = this.altairConfig.tab_size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
[ngClass]="{ 'hide-doc': (showDocs$ | async) !== true }"
[isLoading]="docsIsLoading$ | async"
[addQueryDepthLimit]="addQueryDepthLimit$ | async"
[hideDeprecatedDocItems]="hideDeprecatedDocItems$ | async"
[tabSize]="tabSize$ | async"
[lastUpdatedAt]="schemaLastUpdatedAt$ | async"
(setDocViewChange)="setDocView($event)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export class WindowComponent implements OnInit {
addQueryDepthLimit$: Observable<number>;
tabSize$: Observable<number>;
disableLineNumbers$: Observable<boolean | undefined>;
hideDeprecatedDocItems$: Observable<boolean | undefined>;
enableExperimental$: Observable<boolean | undefined>;
betaDisableNewEditor$: Observable<boolean | undefined>;
autoscrollResponseList$: Observable<boolean>;
Expand Down Expand Up @@ -175,6 +176,9 @@ export class WindowComponent implements OnInit {
this.disableLineNumbers$ = this.store.pipe(
select((state) => state.settings.disableLineNumbers)
);
this.hideDeprecatedDocItems$ = this.store.pipe(
select((state) => state.settings.hideDeprecatedDocItems)
);
this.collections$ = this.store.pipe(select((state) => state.collection.list));
this.activeWindowId$ = this.store.pipe(
select((state) => state.windowsMeta.activeWindowId)
Expand Down
5 changes: 5 additions & 0 deletions packages/altair-core/src/types/state/settings.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ export interface SettingsState {
*/
disableLineNumbers?: boolean;

/**
* Hides deprecated Doc items
*/
hideDeprecatedDocItems?: boolean;

/**
* Specify custom theme config to override the specified theme values
*/
Expand Down

0 comments on commit 50adf9f

Please sign in to comment.