MCPcopy
hub / github.com/apollographql/apollo-client / getDefaultValues

Function getDefaultValues

packages/apollo-utilities/src/getFromAST.ts:190–217  ·  view source on GitHub ↗
(
  definition: OperationDefinitionNode | undefined,
)

Source from the content-addressed store, hash-verified

188}
189
190export function getDefaultValues(
191 definition: OperationDefinitionNode | undefined,
192): { [key: string]: JsonValue } {
193 if (
194 definition &&
195 definition.variableDefinitions &&
196 definition.variableDefinitions.length
197 ) {
198 const defaultValues = definition.variableDefinitions
199 .filter(({ defaultValue }) => defaultValue)
200 .map(
201 ({ variable, defaultValue }): { [key: string]: JsonValue } => {
202 const defaultValueObj: { [key: string]: JsonValue } = {};
203 valueToObjectRepresentation(
204 defaultValueObj,
205 variable.name,
206 defaultValue as ValueNode,
207 );
208
209 return defaultValueObj;
210 },
211 );
212
213 return assign({}, ...defaultValues);
214 }
215
216 return {};
217}
218
219/**
220 * Returns the names of all variables declared by the operation.

Callers 4

getFromAST.tsFile · 0.90
writeResultToStoreMethod · 0.90
diffQueryAgainstStoreMethod · 0.90
transformMethod · 0.90

Calls 2

assignFunction · 0.90

Tested by

no test coverage detected