Skip to content

Commit

Permalink
don't pass shouldPersistHeaders to fetcher anymore (#2684)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasheyenbrock committed Aug 24, 2022
1 parent 5369462 commit be736d0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
13 changes: 13 additions & 0 deletions .changeset/ninety-tips-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@graphiql/toolkit': minor
---

BREAKING: Don't pass `shouldPersistHeaders` anymore when invoking the fetcher function. This value can be looked up by consuming the `EditorContext`:
```js
import { useEditorContext } from '@graphiql/react';

function MyComponent() {
const { shouldPersistHeaders } = useEditorContext();
// Do things...
}
```
3 changes: 0 additions & 3 deletions packages/graphiql-react/src/execution.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export function ExecutionContextProvider(props: ExecutionContextProviderProps) {
headerEditor,
queryEditor,
responseEditor,
shouldPersistHeaders,
variableEditor,
updateActiveTabValues,
} = useEditorContext({ nonNull: true, caller: ExecutionContextProvider });
Expand Down Expand Up @@ -250,7 +249,6 @@ export function ExecutionContextProvider(props: ExecutionContextProviderProps) {
},
{
headers: headers ?? undefined,
shouldPersistHeaders,
documentAST: queryEditor.documentAST ?? undefined,
},
);
Expand Down Expand Up @@ -311,7 +309,6 @@ export function ExecutionContextProvider(props: ExecutionContextProviderProps) {
props.operationName,
queryEditor,
responseEditor,
shouldPersistHeaders,
stop,
subscription,
updateActiveTabValues,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ describe('createGraphiQLFetcher', () => {
]);
const res = await fetcher(
{ query: getIntrospectionQuery(), operationName: 'IntrospectionQuery' },
{
documentAST: exampleIntrospectionDocument,
shouldPersistHeaders: false,
},
{ documentAST: exampleIntrospectionDocument },
);
expect(res).toEqual('hey!');
});
Expand Down
6 changes: 0 additions & 6 deletions packages/graphiql-toolkit/src/create-fetcher/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ export type FetcherParams = {

export type FetcherOpts = {
headers?: { [key: string]: any };
/**
* @deprecated This property will be removed in the next major version of
* `graphiql`, it just echoes back the value passed as prop to the `GraphiQL`
* component with a default value of `false`
*/
shouldPersistHeaders?: boolean;
documentAST?: DocumentNode;
};

Expand Down

0 comments on commit be736d0

Please sign in to comment.