| 82 | }; |
| 83 | |
| 84 | export interface IMockStore { |
| 85 | schema: GraphQLSchema; |
| 86 | /** |
| 87 | * Get a field value from the store for the given type, key and field |
| 88 | * name — and optionally field arguments. If the field name is not given, |
| 89 | * a reference to the type will be returned. |
| 90 | * |
| 91 | * If the the value for this field is not set, a value will be |
| 92 | * generated according to field return type and mock functions. |
| 93 | * |
| 94 | * If the field's output type is a `ObjectType` (or list of `ObjectType`), |
| 95 | * it will return a `Ref` (or array of `Ref`), ie a reference to an entity |
| 96 | * in the store. |
| 97 | * |
| 98 | * Example: |
| 99 | * ```ts |
| 100 | * store.get('Query', 'ROOT', 'viewer'); |
| 101 | * > { $ref: { key: 'abc-737dh-djdjd', typeName: 'User' } } |
| 102 | * store.get('User', 'abc-737dh-djdjd', 'name') |
| 103 | * > "Hello World" |
| 104 | * ``` |
| 105 | */ |
| 106 | get<KeyT extends KeyTypeConstraints = string, ReturnKeyT extends KeyTypeConstraints = string>( |
| 107 | args: GetArgs<KeyT>, |
| 108 | ): unknown | Ref<ReturnKeyT>; |
| 109 | /** |
| 110 | * Shorthand for `get({typeName, key, fieldName, fieldArgs})`. |
| 111 | */ |
| 112 | get<KeyT extends KeyTypeConstraints = string, ReturnKeyT extends KeyTypeConstraints = string>( |
| 113 | typeName: string, |
| 114 | key: KeyT, |
| 115 | fieldNameOrFieldNames: string | string[], |
| 116 | fieldArgs?: string | { [argName: string]: any }, |
| 117 | ): unknown | Ref<ReturnKeyT>; |
| 118 | /** |
| 119 | * Get a reference to the type. |
| 120 | */ |
| 121 | get<KeyT extends KeyTypeConstraints = string>( |
| 122 | typeName: string, |
| 123 | keyOrDefaultValue?: KeyT | { [fieldName: string]: any }, |
| 124 | defaultValue?: { [fieldName: string]: any }, |
| 125 | ): unknown | Ref<KeyT>; |
| 126 | |
| 127 | /** |
| 128 | * Shorthand for `get({typeName: ref.$ref.typeName, key: ref.$ref.key, fieldName, fieldArgs})` |
| 129 | * @param ref |
| 130 | * @param fieldNameOrFieldNames |
| 131 | * @param fieldArgs |
| 132 | */ |
| 133 | get<KeyT extends KeyTypeConstraints = string, ReturnKeyT extends KeyTypeConstraints = string>( |
| 134 | ref: Ref<KeyT>, |
| 135 | fieldNameOrFieldNames: string | string[], |
| 136 | fieldArgs?: string | { [argName: string]: any }, |
| 137 | ): unknown | Ref<ReturnKeyT>; |
| 138 | |
| 139 | /** |
| 140 | * Set a field value in the store for the given type, key and field |
| 141 | * name — and optionally field arguments. |
no outgoing calls
no test coverage detected
searching dependent graphs…