You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let itemOne = Mock<TypeOne>(propertyOne: "Hello World")
let itemTwo = Mock<TypeTwo>(propertyTwo: "Goodbye World")
let mock = Mock<OuterItemType>(
description: "This is my outer type",
items: [ itemOne, itemTwo]
)
Note that in this example, itemOne and itemTwo are two different types that are of the same Union type. So for example, our mock would have it defined as as something like
@Field<[MyUnionType]>("items") public var items but the initializer would take items: [AnyMock]? = nil,
In 1.1.1 this worked fine. However in 1.2 after initializing the mock with items, the items property is still nil. And it is not set in the internal dictionary of the object. i.e if we print itemCollection._data it will only show __typename and description. I'm not 100% sure if the union type is relevant, but i believe it is. Because ultimately it is calling
public func _set<T: MockFieldValue>(
_ value: T.MockValueCollectionType.Element?,
for keyPath: KeyPath<O.MockFields, Field<T>>
) {
let field = O._mockFields[keyPath: keyPath]
_data[field.key.description] = (value as? AnyHashable)
}
but in this case value as? AnyHashable is nil. ( value as? [AnyHashable] however would have worked fine ). But i do see there are _set functions here for arrays, but i don't think they work because the typing is based on generics whereas we're passing [AnyMock].
Version
1.2.0
Steps to reproduce the behavior
Create a schema that has a type with a property that is a nested union type of at least two different types.
Generate the code for these types.
Attempt to initialize a mock for the other type with an array of two different union types.
Print the items property, note it is nil even though it was passed to the initializer.
Logs
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered:
Summary
In version 1.1, we had code like
Note that in this example, itemOne and itemTwo are two different types that are of the same Union type. So for example, our mock would have it defined as as something like
@Field<[MyUnionType]>("items") public var items
but the initializer would takeitems: [AnyMock]? = nil,
In 1.1.1 this worked fine. However in
1.2
after initializing the mock withitems
, theitems
property is still nil. And it is not set in the internal dictionary of the object. i.e if we printitemCollection._data
it will only show__typename
anddescription
. I'm not 100% sure if the union type is relevant, but i believe it is. Because ultimately it is callingbut in this case
value as? AnyHashable
is nil. (value as? [AnyHashable]
however would have worked fine ). But i do see there are_set
functions here for arrays, but i don't think they work because the typing is based on generics whereas we're passing[AnyMock]
.Version
1.2.0
Steps to reproduce the behavior
items
property, note it is nil even though it was passed to the initializer.Logs
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: