Closed ArunVicky001 closed 1 year ago
Hey @ArunVicky001, so the Run Script build phase setup for codegen is not updated or recommended any longer starting with the 1.0 release. If you check out this section of the migration guide you will see some info on that.
As for getting your code generation working, you will want to check out the 1.0 documentation for code generation for the proper commands to run for code generation. The basics are that you will need to first create a codegen configuration that is used by the generate command. I recommend reading through the codegen documentation to see if you can get things working, and if you have further questions let me know.
@BobaFetters Thanks for your response, I have successfully executed the command and it has created the model classes into my project based on the query. I followed the below steps to add the created folders in my project
but still I can't able to read the files is that something else should I need to do?
this is my folder structure
I am trying to access GetInboxUnreadCountQuery
class in my viewController
like below in my view controller
it's not showing could please suggest me the right way to solve this issue?
@ArunVicky001 Can you share your apollo-codegen-config.json
so I can see how to codegen is configured? Also can you point me to where in the documentation you found the steps you listed for adding the files to the project? In general what you are showing in the screenshots looks as if you would need to access your query type through it's namespace like MyQuery.GetInboxUnreadCount...
@BobaFetters
apollo-codegen-config.json
source code
{
"schemaName" : "MyQuery",
"options" : {
"cocoapodsCompatibleImportStatements" : true
},
"input" : {
"operationSearchPaths" : [
"**/*.graphql"
],
"schemaSearchPaths" : [
"/Users/vignesh.arunagiri/Documents/XCode/ClientiOS/Schema/schema.json"
]
},
"output" : {
"testMocks" : {
"none" : {
}
},
"schemaTypes" : {
"path" : "./MyQuery",
"moduleType" : {
"embeddedInTarget" : {
"name" : "ClientiOS"
}
}
},
"operations" : {
"inSchemaModule" : {
}
}
}
}
I don't find any documentation to add files in the project in the apollo client iOS. I have searched it and followed the procedures.
I tried this one too but it's also not accessible
MyQuery.GetInboxUnreadCount...
![Uploading Screenshot 2023-05-11 at 10.41.14 PM.png…]()
@ArunVicky001, in the code you shared it shows that GetInboxUnreadCountQuery
is within an extension
on MyQuery
; we do this for embedded module types to minimize the chance of a type conflict. You will have to access it through the MyQuery
namespace, so you should change your view controller code to [MyQuery.GetInboxUnreadCountQuery.Data.getInboxUnreadCount]
.
@calvincestari @BobaFetters
if you see the screenshot MyQuery folder is not properly adding into the project it's shows "?" beside the folder name
if you see the screenshot MyQuery folder is not properly adding into the project it's shows "?" beside the folder name
I believe that is the git status of the files in your repo. It has nothing to do with Apollo iOS.
then it's fine, Could you please help me to get the MYQuery
class accessible in the ViewController? also please check the sample project and suggest me
The files were not correctly added to the project. If you look at 'Compile Sources' in the 'Build Phases' tab of the project, you'll see that none of the .swift
files were added to the target. They're not being compiled which means your project doesn't know about them.
Remove the MyQuery folder from your project and add it again, then it should look like this:
Then you can use the MyQuery
namespace and GetInboxUnreadCountQuery
within it.
How did you added the MyQuery folder in the project could you please share the steps? because there I am committing the mistake
Got it, it should be Create Groups instead of Create folder references and then manually we need to add those files into the compile sources.
and then manually we need to add those files into the compile sources.
No, you do not need to manually add them. Xcode will automatically do it.
I'm going to close this issue as there is nothing actionable for us in Apollo iOS. Your project should work fine once the generated files are correctly added and compiled into the target.
@calvincestari is that the right way to do this, and it's not mentioned anywhere in the documentation. could you please confirm this.
@ArunVicky001, you need to add the generated files to your project in a way that is suitable for your project and so that they're compiled into the target. We don't include step by step instructions for Xcode because we require that users already have the knowledge to do that.
after added the folder into the project I just ran the application and the files are not being added in the compile resources. please verify it again.
It sounds like you didn't select the ClientiOS
target for 'Add to targets:' when adding the files to your project. Adding it to the target is what gets it included in the build step.
Question
Hi I have an existing project using an old Apollo build(
0.53.0
) w/cocoapods and am trying to upgrade to1.0.7
. I followed all the steps here:https://www.apollographql.com/docs/ios/migrations/1.0/#breaking-changes
using the Xcode project' set up that is outlined in below steps
pod 'Apollo', '~> 1.0'
2. Created a GraphQL schema file (usually a .json file) that describes your API. 3.In your Xcode project, create a new build phase to generate code. a. Open your project settings and go to the "Build Phases" tab. b. Click the plus button in the top-left corner and select "New Run Script Phase". c. In the script text field, enter the following:./Pods/Apollo/apollo-ios-cli generate path/to/schema.graphql --output API --target ios
the above command is not working and it throwing me an error like belowalso I tired with
./Pods/Apollo/apollo-ios-cli generate path/to/schema.graphql --outputDirectory API --target ios
getting same error belowplease suggest me a right way migrate the library from
0.53.0 to 1.0.7
Thank you