Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added displayOptions right type to MiddlewareOptions #178

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions src/components/Voyager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getIntrospectionQuery } from 'graphql/utilities';

import { getSchema, extractTypeId } from '../introspection';
import { SVGRender, getTypeGraph } from '../graph/';
import { WorkerCallback } from '../utils/types';
import { WorkerCallback, VoyagerDisplayOptions } from '../utils/types';

import * as React from 'react';
import * as PropTypes from 'prop-types';
Expand All @@ -19,16 +19,7 @@ import './viewport.css';

type IntrospectionProvider = (query: string) => Promise<any>;

export interface VoyagerDisplayOptions {
rootType?: string;
skipRelay?: boolean;
skipDeprecated?: boolean;
showLeafFields?: boolean;
sortByAlphabet?: boolean;
hideRoot?: boolean;
}

const defaultDisplayOptions = {
const defaultDisplayOptions: VoyagerDisplayOptions = {
rootType: undefined,
skipRelay: true,
skipDeprecated: true,
Expand Down
3 changes: 2 additions & 1 deletion src/middleware/render-voyager-page.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const { version } = require('../package.json');
import { VoyagerDisplayOptions } from '../utils/types';

export interface MiddlewareOptions {
endpointUrl: string;
displayOptions?: object;
displayOptions?: VoyagerDisplayOptions;
headersJS?: string;
}

Expand Down
9 changes: 9 additions & 0 deletions src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,12 @@ export type WorkerCallback = (
path: string,
relative: boolean,
) => Promise<Worker>;

export interface VoyagerDisplayOptions {
rootType?: string;
skipRelay?: boolean;
skipDeprecated?: boolean;
showLeafFields?: boolean;
sortByAlphabet?: boolean;
hideRoot?: boolean;
}