-
Notifications
You must be signed in to change notification settings - Fork 734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLI code generation error when the server schema has types with long names #3131
Comments
I have the very same problem with types created by Contentful. Those are ridiculously long and I would also like to make Contentful aware of this. Fortunately, I don't need those types for my queries and I can manually remove them from the schema. I couldn't find an option to exclude types from the schema in the apollo config, that would help me already. But for those who need to use those types, it's a bad situation. |
Hi 👋🏻 - I don't really have a good answer to this other than the type should be renamed. I think Apollo Kotlin suffers the same problem but their codegen engine has the ability to include/exclude types based on a regex pattern; Apollo iOS doesn't have that feature. I don't think adding filename length logic to our codegen engine is appropriate because that may cause other issues when the directory paths exceed 255 characters causing the file to be created somewhere else entirely; my answer in that case would be similarly to trim down the directory paths. A local script to rename the type before codegen could be used but that's tedious and would have to be done before each run of code generation.
Yes, when those types are being used the only option is to rename them them. A custom directive would be particularly useful here. |
I was in touch with Contentful support today and they said they just released a fix today to handle those long names (I couldn't test yet because the space I'm consuming doesn't belong to my team so I couldn't refresh the schema yet). Still, these long names are generated by Contentful itself when building the server schema to download. It's not something we can just rename. Anyway, can't the CLI detect those large names objects during the code generation and try to truncate (or ask for the user suggestion to change) only the file name (since this is a MacOS limitation) but keep the object name inside as it is (since Swift doesn't have issues with large names for objects)? I think this might mitigate the problem. |
We're deliberating about this within the team but IMO a custom directive is still the correct way to solve this and a few other use cases too. |
We've decided as a team that a custom directive to rename a schema type is the preferred solution. I've added it to our Minor Releases milestone but it has no particular delivery date attached to it. We're always willing to work with community contributions if a feature is needed sooner than we can get to implementing it. |
We're going to track this feature in #3283 which we hope to begin work on shortly. |
Summary
After downloading the server's schema with the Apollo CLI, I'm facing this issue when running the generate command from the CLI:
Other files from schema were properly created with the CLI command but this one failed because this object name has more than 255 characters (the MacOS limitation for file names).
Version
1.3.1
Steps to reproduce the behavior
fetch-schema
command to download the server schema (schema.graphqls
) with some long object inside. Example:generate
command with a.graphql
operation file in the same downloaded schema file folderLogs
Error: cannotCreateFile(at: "/Users/moliveira/ios-apps/iOSApp/LetsGetChecked/ResultsNarrativesAPI/Schema/Objects/ContainerColumnsOrCallToActionBannerOrContainerSectionTwoColumnOrFaqOrSectionComparisonTableOrSectionGridOrSectionHeroOrSectionIconCarouselOrSectionLogosOrSectionOneColumnOrSectionProductCardsOrSectionReviewsOrSectionStepsOrSectionTabbedInformationOrSectionTestimonialCarouselOrSectionTrustpilot.graphql.swift")
Anything else?
No response
The text was updated successfully, but these errors were encountered: