Comments (9)
Thank you @calvincestari and @AnthonyMDev , i did search the docs for that directive but was unable to find it. Thanks for pointing it out and for the swift replies! Will try it out again today and see if I can make it work.
from apollo-ios.
Making matters difficult is when i try to test this out, i run into this crash
GraphQLCompiler/JavaScriptBridge.swift:271: Precondition failed: Expected JavaScript object but found: undefined
from apollo-ios.
Hi @scottasoutherland - I agree with should get some specific documentation up for this, I thought we had some already. We'll likely need a new place in the documentation where we can describe custom directives.
That directive is quite easy to use though:
- Add the directive to an operation or fragment, e.g:
query ExampleOperation @import(module: "ModuleName") { .. }
ModuleName
needs to be the name of a defined target/module that is accessible to the code where the operation will be generated.
Note that this is not intended to be a way to link schemas though, so any target/module you want to import into the operation file must have been part of the code generation execution that generated the operation in question.
from apollo-ios.
Making matters difficult is when i try to test this out, i run into this crash
GraphQLCompiler/JavaScriptBridge.swift:271: Precondition failed: Expected JavaScript object but found: undefined
If you remove @import
does the error stop and codegen succeeds?
from apollo-ios.
Note that this is not intended to be a way to link schemas though, so any target/module you want to import into the operation file must have been part of the code generation execution that generated the operation in question.
So in our case we have 1 schema, and we have 3 different libraries we build that each have their own queries against that schema. We use some fragments in all 3 of them but currently we just copy the files so we end up with LibraryOne.myFragment, LibraryTwo.myFragment, LibraryThree.myFragment which are all effectively the same type but not actually interchangeable. What we'd like to do is import LibraryOne into LibraryTwo & LibraryThree and use LibraryOne.MyFragment everywhere.
If this is not what this is for, can you explain the use case for the directive ? In what case would you need to import a library that has nothing to do with the generated code ?
If you remove @import does the error stop and codegen succeeds?
After messing with it, the problem was not the imports, the problem was the missing fragments that i moved. It appears to be a volume of errors or something because if only one fragment is missing it flags that correctly but when i removed all of the re-used fragments it crashes instead.
from apollo-ios.
So in our case we have 1 schema, and we have 3 different libraries we build that each have their own queries against that schema. We use some fragments in all 3 of them but currently we just copy the files so we end up with LibraryOne.myFragment, LibraryTwo.myFragment, LibraryThree.myFragment which are all effectively the same type but not actually interchangeable. What we'd like to do is import LibraryOne into LibraryTwo & LibraryThree and use LibraryOne.MyFragment everywhere.
Yes, this sounds like what it was intended for.
from apollo-ios.
There is documentation of that directive here. Perhaps this docs page is too difficult to discover right now?
from apollo-ios.
Thanks @AnthonyMDev.
@scottasoutherland I'm going to close this issue now as there doesn't seem to be anything actionable. If you have further issues getting @import
to work feel free to comment back here and we'll take a look - thanks.
from apollo-ios.
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.
from apollo-ios.
Related Issues (20)
- Add support for incremental cache reads
- Avoid File Overwriting for Unchanged Files HOT 1
- `InMemoryNormalizedCache` is a memory bomb HOT 5
- iOS 13.0 or newer error - compile fails HOT 3
- Custom Scalar | ApolloAPI.JSONDecodingError.couldNotConvert(value: AnyHashable to: Swift.String HOT 5
- How should I continue after handleErrorAsync inside a custom ApolloErrorInterceptor? HOT 5
- Defining a CustomScalarType which is [String:Any] HOT 10
- Deprecate `legacyResponse` and prepare for partial/incremental caching HOT 2
- Custom scalar isn't being respected HOT 7
- @defer issue HOT 8
- Add debugDescription api for Apollo generated types
- Circular reference Build Error HOT 6
- Invalid redeclaration of synthesized property '_id' HOT 7
- Split/Hybrid Caching between InMemory and SQL review and thoughts HOT 2
- ID as a custom scalar HOT 6
- Bug: Cache writes of incremental responses uses incorrect parent key (custom cache keys)
- Incorrect PR link in release notes for version 1.11.0 HOT 2
- apollo-ios-cli deprecated --schema-name HOT 2
- Confused about cache behavior HOT 2
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.