mock_src.imockstore
#
Interface: IMockStoremock/src.IMockStore
#
Implemented by#
Table of contents#
Properties#
Methods#
Properties#
schema• schema: GraphQLSchema
Defined in: packages/mock/src/types.ts:69
#
Methods#
getâ–¸ get<KeyT, ReturnKeyT\>(args
: GetArgs<KeyT\>): unknown
Get a field value from the store for the given type, key and field name — and optionally field arguments. If the field name is not given, a reference to the type will be returned.
If the the value for this field is not set, a value will be generated according to field return type and mock functions.
If the field's output type is a ObjectType
(or list of ObjectType
),
it will return a Ref
(or array of Ref
), ie a reference to an entity
in the store.
Example:
#
Type parameters:Name | Type | Default |
---|---|---|
KeyT | KeyTypeConstraints | string |
ReturnKeyT | KeyTypeConstraints | string |
#
Parameters:Name | Type |
---|---|
args | GetArgs<KeyT\> |
Returns: unknown
Defined in: packages/mock/src/types.ts:90
â–¸ get<KeyT, ReturnKeyT\>(typeName
: string, key
: KeyT, fieldNameOrFieldNames
: string | string[], fieldArgs?
: string | { [argName: string]: any; }): unknown
Shorthand for get({typeName, key, fieldName, fieldArgs})
.
#
Type parameters:Name | Type | Default |
---|---|---|
KeyT | KeyTypeConstraints | string |
ReturnKeyT | KeyTypeConstraints | string |
#
Parameters:Name | Type |
---|---|
typeName | string |
key | KeyT |
fieldNameOrFieldNames | string | string[] |
fieldArgs? | string | { [argName: string]: any; } |
Returns: unknown
Defined in: packages/mock/src/types.ts:96
â–¸ get<KeyT\>(typeName
: string, keyOrDefaultValue?
: KeyT | { [fieldName: string]: any; }, defaultValue?
: { [fieldName: string]: any; }): unknown
Get a reference to the type.
#
Type parameters:Name | Type | Default |
---|---|---|
KeyT | KeyTypeConstraints | string |
#
Parameters:Name | Type |
---|---|
typeName | string |
keyOrDefaultValue? | KeyT | { [fieldName: string]: any; } |
defaultValue? | object |
Returns: unknown
Defined in: packages/mock/src/types.ts:105
â–¸ get<KeyT, ReturnKeyT\>(ref
: Ref<KeyT\>, fieldNameOrFieldNames
: string | string[], fieldArgs?
: string | { [argName: string]: any; }): unknown
Shorthand for get({typeName: ref.$ref.typeName, key: ref.$ref.key, fieldName, fieldArgs})
#
Type parameters:Name | Type | Default |
---|---|---|
KeyT | KeyTypeConstraints | string |
ReturnKeyT | KeyTypeConstraints | string |
#
Parameters:Name | Type |
---|---|
ref | Ref<KeyT\> |
fieldNameOrFieldNames | string | string[] |
fieldArgs? | string | { [argName: string]: any; } |
Returns: unknown
Defined in: packages/mock/src/types.ts:117
#
setâ–¸ set<KeyT\>(args
: SetArgs<KeyT\>): void
Set a field value in the store for the given type, key and field name — and optionally field arguments.
If the the field return type is an ObjectType
or a list of
ObjectType
, you can set references to other entity as value:
But it also supports nested set:
#
Type parameters:Name | Type | Default |
---|---|---|
KeyT | KeyTypeConstraints | string |
#
Parameters:Name | Type |
---|---|
args | SetArgs<KeyT\> |
Returns: void
Defined in: packages/mock/src/types.ts:153
â–¸ set<KeyT\>(typeName
: string, key
: KeyT, fieldName
: string, value?
: unknown): void
Shorthand for set({typeName, key, fieldName, value})
.
#
Type parameters:Name | Type | Default |
---|---|---|
KeyT | KeyTypeConstraints | string |
#
Parameters:Name | Type |
---|---|
typeName | string |
key | KeyT |
fieldName | string |
value? | unknown |
Returns: void
Defined in: packages/mock/src/types.ts:158
â–¸ set<KeyT\>(typeName
: string, key
: KeyT, values
: { [fieldName: string]: any; }): void
Set the given field values to the type with key.
#
Type parameters:Name | Type | Default |
---|---|---|
KeyT | KeyTypeConstraints | string |
#
Parameters:Name | Type |
---|---|
typeName | string |
key | KeyT |
values | object |
Returns: void
Defined in: packages/mock/src/types.ts:163
â–¸ set<KeyT\>(ref
: Ref<KeyT\>, fieldName
: string, value?
: unknown): void
Shorthand for set({ref.$ref.typeName, ref.$ref.key, fieldName, value})
.
#
Type parameters:Name | Type | Default |
---|---|---|
KeyT | KeyTypeConstraints | string |
#
Parameters:Name | Type |
---|---|
ref | Ref<KeyT\> |
fieldName | string |
value? | unknown |
Returns: void
Defined in: packages/mock/src/types.ts:172
â–¸ set<KeyT\>(ref
: Ref<KeyT\>, values
: { [fieldName: string]: any; }): void
Set the given field values to the type with ref.
#
Type parameters:Name | Type | Default |
---|---|---|
KeyT | KeyTypeConstraints | string |
#
Parameters:Name | Type |
---|---|
ref | Ref<KeyT\> |
values | object |
Returns: void
Defined in: packages/mock/src/types.ts:177