( definition: OperationDefinitionNode | undefined, )
| 188 | } |
| 189 | |
| 190 | export 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. |
no test coverage detected