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
When generating mock object types with the code generation tool we are seeing cases where the extension on the Mock type will create a convenience init that takes no parameters and calls self.init() thus resulting the compiler warning "Function call causes an infinite recursion."
Versions
Please fill in the versions you're currently using:
apollo-ios SDK version: 1.0.2
Xcode version: 14.1
Swift version: 5.7
Package manager: 5.7
Steps to reproduce
We are seeing this when we generate code for a query that doesn't ask for an entire sub-object type. For example say in our schema we define a type in our schema that has this kind of property graph:
When we run the code generation tool configuring it to generate mock object we would expect that no mock type would be generated for ValuePropLink. But instead we see this file created:
import ApolloTestSupport
import SharedGraphTypes
publicclassValuePropLink:MockObject{publicstaticletobjectType:Object=FederatedGraphSharedTypes.Objects.ValuePropLink
publicstaticlet_mockFields=MockFields()publictypealiasMockValueCollectionType=Array<Mock<ValuePropLink>>publicstructMockFields{}}publicextensionMockwhere O ==ValuePropLink{convenienceinit(){self.init()}}
As you can see, if one where to call the convenience init where O is ValuePropLink it would just call itself recursively until the system runs out of stack memory.
What we would expect to see is the mock type would be generated. Looking through the code It appears that the mock code generator isn't checking to see if the field list is empty before writing the mock code template out to disk.
The text was updated successfully, but these errors were encountered:
Bug report
When generating mock object types with the code generation tool we are seeing cases where the extension on the
Mock
type will create a convenience init that takes no parameters and callsself.init()
thus resulting the compiler warning "Function call causes an infinite recursion."Versions
Please fill in the versions you're currently using:
apollo-ios
SDK version: 1.0.2Steps to reproduce
We are seeing this when we generate code for a query that doesn't ask for an entire sub-object type. For example say in our schema we define a type in our schema that has this kind of property graph:
Stuff
id: Int!
title: String
ValuePropLink
url: String!
id: Int!
And we write a query that's something like:
When we run the code generation tool configuring it to generate mock object we would expect that no mock type would be generated for ValuePropLink. But instead we see this file created:
As you can see, if one where to call the convenience init where
O
isValuePropLink
it would just call itself recursively until the system runs out of stack memory.What we would expect to see is the mock type would be generated. Looking through the code It appears that the mock code generator isn't checking to see if the field list is empty before writing the mock code template out to disk.
The text was updated successfully, but these errors were encountered: