-
Notifications
You must be signed in to change notification settings - Fork 726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generated mocks in test target missing @testable annotation against main target #3353
Comments
I think the selection set initializers config option was built after the migration guides. That may be what you're looking for? |
Thank you @calvincestari ! That worked 👍 Whilst it fixes my problem, I wonder if we still would want the ability to specify whether the Using the |
@michaelloo do you mind sharing your codegen configuration so I can see how you're putting things together. |
Yeah, I do agree with you @michaelloo. I'm thinking we can determine if the generated models will be |
@calvincestari here is my latest config (with some obscured params): {
"schemaNamespace" : "XXXSchema",
"schemaDownload": {
"downloadMethod": {
"introspection": {
"endpointURL": "some.url/graphql",
"httpMethod": { "POST": {} },
"includeDeprecatedInputValues": false,
"outputFormat": "JSON"
}
},
"downloadTimeout": 60,
"outputPath": "./graphql/"
},
"input" : {
"operationSearchPaths" : ["**/*.graphql"],
"schemaSearchPaths" : ["**/schema.json"]
},
"output" : {
"testMocks" : { "none" : {} },
"schemaTypes" : {
"path" : "./GeneratedFiles",
"moduleType" : { "embeddedInTarget" : { "name": "XXX" } }
},
"operations" : { "inSchemaModule" : {} }
},
"options": {
"cocoapodsCompatibleImportStatements": true,
"selectionSetInitializers": {
"localCacheMutations" : true,
"namedFragments" : true,
"operations" : true
}
}
} I had "testMocks" with "absolute" configuration in there when trying the @AnthonyMDev that could work if that is the assumption we take that if the accessModifier for the GQL models are not Is adding another AccessModifier case called |
Our view is that test mocks are purely for testing; that was the intent of their design. There is also a future where test mocks are deprecated. |
This should be fixed by #362 which will be released within the next week. If you are still experiencing this bug once that is released, please let us know! |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo iOS usage and allow us to serve you better. |
Summary
At work, we recently updated Apollo from 0.52.0 to 1.9.0 (I know thats a fairly big jump!) via Cocoapods.
We used to be able to create test data for the generated GraphQL models using the initialiser, but as referred to in the migration document, we are meant to now use
Mock
s andApolloTestSupport
instead.I'd like to generate the tests in the test target since that is where they are needed, they do not need to be shipped in the framework I am packaging but doing so does not compile as the generated files are not
public
and the generated mocks cannot find them.Version
1.9.0
Steps to reproduce the behavior
Project setup:
Example of Podfile setup (as I cannot share work related code):
Things I've tried:
@testable
annotation to find theinternal
generated GraphQL files.public
, but that means exposing my data models to any other codebase that uses the framework, which isn't idealimport
the main target (and as mentioned, i'd like to avoid shipping them in the framework if possible)I feel that the
output.testMocks
code generation should either:@testable
if we are adding this to a test target so that we dont need to declare thingspublic
for the sake of tests, orAny other options would be greatly appreciated!
Logs
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: