-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] bound fetcher function could cause infinite loop
This fixes an issue introduced by 82b059d which refetched schema when the fetching function changes. If the GraphiQL React component is provided with a bound function, like `this.fetcher.bind(this)` then every time it is rendered, it will fetch a new schema. If the result of fetching the schema causes any changes which trigger a rerender, this can result in an infinite loop. This behavior is removed by this diff, so providing a new fetching function no longer refetches the schema. In addition, this also solves a race condition where a provided schema would be replaced by the pending fetched schema. In practice, looking for a different fetching function is also insufficient for the original goal of refetching a schema when the backing server has changed, as that bit of information could very possibly be held in some other encapsulated state, which would not result in function identity changing. To actually satisfy the original goal, this provides the ability for setting the schema (and also query and variables) to `null` to represent no value, whereas the value `undefined` continues to be interpretted as not provided, falling back to the existing default behaviors. For installations of GraphiQL which seek to swap out different fetching functions and schemas, it will work best if the schema is created and managed outside of GraphiQL's default behavior.
- Loading branch information
Showing
2 changed files
with
68 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters