Summary
Hello everyone,
we are in the migration to version 2.0.2 and noticed an issue with code generation in test mocks. We receive error: no exact matches in call to initializer when a required field is using a custom scalar type. The generated default value in init cannot access .init(_jsonValue:).
17 | public extension Mock where O == Viewer {
18 | convenience init(
19 | imageURL: Demo.URL = try! .init(_jsonValue: "")
| `- error: no exact matches in call to initializer
20 | ) {
21 | self.init()
Thanks for looking into this. Keep up the good work.
Version
2.0.2
Steps to reproduce the behavior
We tried to isolate the issue as much as possible in a small example project. The included schema is using the same custom scalar for URL we have in our production schema:
https://github.com/akoslowski/apollo-mock-codegen-issue
An observation: we saw that adding @_spi(Internal) to the generated mock makes the initializer available.
index a0defbc..3787741 100644
--- a/Tests/GraphQLMocks/Viewer+Mock.graphql.swift
+++ b/Tests/GraphQLMocks/Viewer+Mock.graphql.swift
@@ -1,7 +1,7 @@
// @generated
// This file was automatically generated and should not be edited.
-import ApolloTestSupport
+@_spi(Internal) import ApolloTestSupport
@testable import Demo
public final class Viewer: MockObject {
@@ -15,7 +15,7 @@ public final class Viewer: MockObject {
}
public extension Mock where O == Viewer {
- convenience init(
+ @_spi(Internal) convenience init(
imageURL: Demo.URL = try! .init(_jsonValue: "")
) {
self.init()
Logs
Anything else?
No response
Summary
Hello everyone,
we are in the migration to version 2.0.2 and noticed an issue with code generation in test mocks. We receive
error: no exact matches in call to initializerwhen a required field is using a custom scalar type. The generated default value ininitcannot access.init(_jsonValue:).Thanks for looking into this. Keep up the good work.
Version
2.0.2
Steps to reproduce the behavior
We tried to isolate the issue as much as possible in a small example project. The included schema is using the same custom scalar for
URLwe have in our production schema:https://github.com/akoslowski/apollo-mock-codegen-issue
An observation: we saw that adding
@_spi(Internal)to the generated mock makes the initializer available.Logs
Anything else?
No response