-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #3051
- Loading branch information
Showing
23 changed files
with
259 additions
and
64 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { GraphQLInputType, GraphQLDefaultValueUsage } from './definition'; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export function getCoercedDefaultValue( | ||
usage: GraphQLDefaultValueUsage, | ||
type: GraphQLInputType, | ||
): unknown; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { invariant } from '../jsutils/invariant'; | ||
|
||
import { valueFromAST } from '../utilities/valueFromAST'; | ||
|
||
import type { GraphQLInputType, GraphQLDefaultValueUsage } from './definition'; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export function getCoercedDefaultValue( | ||
usage: GraphQLDefaultValueUsage, | ||
type: GraphQLInputType, | ||
): mixed { | ||
if (usage.value !== undefined) { | ||
return usage.value; | ||
} | ||
// Memoize the result of coercing the default value in a hidden field. | ||
let coercedValue = (usage: any)._memoizedCoercedValue; | ||
// istanbul ignore else (memoized case) | ||
if (coercedValue === undefined) { | ||
coercedValue = valueFromAST(usage.literal, type); | ||
invariant( | ||
coercedValue !== undefined, | ||
'Literal cannot be converted to value for this type', | ||
); | ||
(usage: any)._memoizedCoercedValue = coercedValue; | ||
} | ||
return coercedValue; | ||
} |
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
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
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
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
Oops, something went wrong.