Closed arnauddorgans closed 7 months ago
@arnauddorgans Based on what you posted I am assuming the GQLUser
fragment (and ProfileAPI) are part of a separate schema from your SearchUsers
query? The @import
directive is used for handling Swift module imports based on how you have your code generation configured to output your files, not including items from a separate GraphQL schema into another.
The general use case is say you have your schema schema types (such as your fragments) generated into target/package A, while you may have various sets of operations that you have being generated into different modules B, C, and D, respectively. If you are using a fragment from A in an operation in package B, the generated code wouldn't compile without importing package A into the generated operation file in package B. Using this @import
directive allows you to do this at the schema level and have it handled by code generation instead of having to do it manually.
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.
Question
I saw in the latest release we can import modules from the definition line, but I need help understanding the purpose of being able to.
I have a fragment in
ProfileAPI
module namedGQLUser
but Apollo refuses to generate the file becauseUnknown fragment "GQLUser"
Is it supposed to work?