-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #444 from convoyinc/jdeff/apollo-v3
Update apollo client to v3 and TypeScript to latest
- Loading branch information
Showing
23 changed files
with
329 additions
and
137 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
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
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,42 @@ | ||
// We only depend on graphql for its types; nothing at runtime. | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { ValueNode, VariableNode } from 'graphql'; | ||
import { InvariantError } from 'ts-invariant'; | ||
import { VariableValue } from '@apollo/client/utilities'; | ||
|
||
// Note: These functions were originally a part of apollo-utilities, but were | ||
// removed 87c7a2bc as they were unused within the apollo-client project. | ||
|
||
function defaultValueFromVariable(_node: VariableNode) { | ||
throw new InvariantError(`Variable nodes are not supported by valueFromNode`); | ||
} | ||
|
||
/** | ||
* Evaluate a ValueNode and yield its value in its natural JS form. | ||
*/ | ||
export function valueFromNode( | ||
node: ValueNode, | ||
onVariable: VariableValue = defaultValueFromVariable, | ||
): any { | ||
switch (node.kind) { | ||
case 'Variable': | ||
return onVariable(node); | ||
case 'NullValue': | ||
return null; | ||
case 'IntValue': | ||
return parseInt(node.value); | ||
case 'FloatValue': | ||
return parseFloat(node.value); | ||
case 'ListValue': | ||
return node.values.map(v => valueFromNode(v, onVariable)); | ||
case 'ObjectValue': { | ||
const value: { [key: string]: any } = {}; | ||
for (const field of node.fields) { | ||
value[field.name.value] = valueFromNode(field.value, onVariable); | ||
} | ||
return value; | ||
} | ||
default: | ||
return node.value; | ||
} | ||
} |
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.