Comments (6)
Thank you @calvincestari ! That worked 👍
Whilst it fixes my problem, I wonder if we still would want the ability to specify whether the import
of the generated mocks should have @testable
in cases where we dont the mocked models to be public
?
Using the Mock
s would actually be beneficial but cannot be used without public
graphql models.
from apollo-ios.
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 Mocks and ApolloTestSupport instead.
I think the selection set initializers config option was built after the migration guides. That may be what you're looking for?
from apollo-ios.
@michaelloo do you mind sharing your codegen configuration so I can see how you're putting things together.
from apollo-ios.
Yeah, I do agree with you @michaelloo. I'm thinking we can determine if the generated models will be public
from the configuration and just know to add @testable
or not without needing another new config option.
from apollo-ios.
@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 Mock
out
@AnthonyMDev that could work if that is the assumption we take that if the accessModifier for the GQL models are not public
, then the mocks are purely for testing. That will couple them together more but might not be a bad thing I guess.
Is adding another AccessModifier case called testable
that we can pass to the existing testMocks.absolute
config? Although this might also not be ideal because it means you could actually create GQL models with @testable
as well and that might not make any sense 🤔
from apollo-ios.
Is adding another AccessModifier case called testable that we can pass to the existing testMocks.absolute config? Although this might also not be ideal because it means you could actually create GQL models with @testable as well and that might not make any sense 🤔
TestMockFileOutput
and SchemaTypesFileOutput.ModuleType
share the same enum so I don't think an internal
case will work there and it is worth duplication of the enum when we can work with assumptions instead?
@AnthonyMDev that could work if that is the assumption we take that if the accessModifier for the GQL models are not public, then the mocks are purely for testing.
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.
from apollo-ios.
Related Issues (20)
- Process Mutation on a Queue when encountering network errors HOT 2
- WebSocketTransport: detect server side completion message. HOT 4
- Invalid type aliases generated on recursive types HOT 1
- The operation couldn’t be completed. (OSStatus error -9847.) HOT 11
- Cannot convert value of type 'GraphQLNullable<[String]>' to expected argument type '[String?]' HOT 10
- SchemaConfiguration.cacheKeyInfo(for:object:) never called? HOT 5
- Watcher not firing after failure to decode response HOT 2
- Cococapods installation should use download script to fetch CLI instead of using embedded binary
- How to know subscription state HOT 1
- Normalised Cache Not Using Data from Different Query HOT 1
- How @import(module:) works? HOT 2
- Unable to generate code HOT 4
- Apollo code-gen fails to compile on Xcode 15.3 with StrictConcurrency enabled HOT 2
- ApolloPagination's loadNext throwing `loadInProgress` incorrectly HOT 16
- Parity with Apollo Kotlin: Ability to Observe ApolloStore Changes? HOT 3
- Narrowly Scoped equality on SelectionSet models HOT 1
- SQLite dependency needs to be bumped to 0.15.0 HOT 3
- codegen: Append type to generated filenames HOT 5
- Add support for SPM `Package.resolved` version `3`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apollo-ios.