swift-graphql
swift-graphql copied to clipboard
How to debug codegen errors?
I'm getting an error when running swift-graphql
, but I can't seem to find a way to get a more descriptive error message?
swift-graphql https://healthcloud.kingstinct.dev/graphql --config swiftgraphql.yml --output graphql.generated.swift
This is all I see (the red background indicates that the command exited with a non-zero exit code):
How do I proceed?
I encountered the same issue as described in issue #203. I found that the crash was due to the force unwrapped line in Fragments.swift:
private var mock: String {
return self.first!.namedType.name.camelCasePreservingSurroundingUnderscores
}
To resolve this, I unwrapped the value safely. If it couldn't be unwrapped, I returned a value that I could search for within the file, which helped me identify the relevant parts of my schema to investigate further. This led me to discover issues with interfaces that were defined in the schema but never used. Once these unused interfaces were removed from the schema, the code generation worked as expected.
Next steps might be to check if the mock value exists before adding the selecting case and removing the force unwrap, but I don't know what the repercussions of that would be in practice.