Skip to content

Commit 7792dc9

Browse files
authored
graphiql 5: push field type on stack too before field (#4006)
* push field type on stack too before field * add comment
1 parent 1e3ec84 commit 7792dc9

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

.changeset/fluffy-beers-build.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphiql/plugin-doc-explorer': patch
3+
---
4+
5+
push field type on stack too before field

packages/graphiql-plugin-doc-explorer/src/context.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ export const docExplorerStore = createStore<DocExplorerStoreType>(
132132
break;
133133
}
134134
case 'Field': {
135+
// Show a field type on stack
136+
if (ref.type) {
137+
push({
138+
name: ref.type.name,
139+
def: ref.type,
140+
});
141+
}
135142
push({
136143
name: ref.field.name,
137144
def: ref.field,

packages/graphiql-react/src/components/provider.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ type GraphiQLProviderProps =
5050

5151
type GraphiQLStore = UseBoundStore<StoreApi<AllSlices>>;
5252

53-
const GraphiQLContext = createContext<RefObject<GraphiQLStore>>(null!);
53+
const GraphiQLContext = createContext<RefObject<GraphiQLStore> | null>(null);
5454

5555
export const GraphiQLProvider: FC<GraphiQLProviderProps> = ({
5656
storage,
@@ -317,7 +317,6 @@ const SynchronizeValue: FC<SynchronizeValueProps> = ({
317317

318318
export function useGraphiQL<T>(selector: (state: AllSlices) => T): T {
319319
const store = useContext(GraphiQLContext);
320-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- fixme
321320
if (!store) {
322321
throw new Error('Missing `GraphiQLContext.Provider` in the tree');
323322
}

0 commit comments

Comments
 (0)