Skip to content

Commit

Permalink
Add defaultQuery to options
Browse files Browse the repository at this point in the history
  • Loading branch information
romeovs committed Jan 30, 2024
1 parent b372907 commit 49a32b1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function Render(props: GraphiQLToolProps) {
return (
<div className='graphiql-tool-wrapper graphiql-container'>
{options.url ? null : <Header url={url} onUrlChange={setUrl} apis={apis} />}
<GraphiQL url={url} />
<GraphiQL url={url} defaultQuery={options.defaultQuery} />
</div>
)
}
1 change: 1 addition & 0 deletions src/graphiql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {useTimedFetcher} from './use-timed'

type GraphiQLProps = {
url: string | null
defaultQuery?: string
}

export function GraphiQL(props: GraphiQLProps) {
Expand Down
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ const GraphiQLTool = lazy(() => import('./component'))
*
* // override the default tool icon
* icon: BlockElementIcon,
*
* // set the default query
* defaultQuery: 'query { ... }'
* }),
* ],
* })
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export type GraphiQLToolConfig = {
name?: string
title?: string
icon?: React.ComponentType
defaultQuery?: string
}

0 comments on commit 49a32b1

Please sign in to comment.