-
Notifications
You must be signed in to change notification settings - Fork 731
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
feat: Add support for .none
module type - Part 1: File Templates
#2229
Conversation
✅ Deploy Preview for apollo-ios-docs ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Sources/ApolloCodegenLib/Templates/ImportStatementTemplate.swift
Outdated
Show resolved
Hide resolved
Tests/ApolloCodegenTests/CodeGeneration/FileGenerators/SchemaModuleFileGeneratorTests.swift
Show resolved
Hide resolved
Tests/ApolloCodegenTests/CodeGeneration/Templates/SwiftPackageManagerModuleTemplateTests.swift
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! We should talk about what to do about shared Fragments, but otherwise this is good to go!
|
||
func render() -> String { | ||
var target: TemplateTarget { .operationFile } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a fragment is being shared across operations and those operations are in separate modules, the Fragment would need to be include in the schema module. We probably need to put some more thought into this.
Sources/ApolloCodegenLib/Templates/ImportStatementTemplate.swift
Outdated
Show resolved
Hide resolved
…s to reuse function to render subject
…2234) * Adapt EnumFileGenerator to FileGenerator * Adapt ObjectFileGenerator to FileGenerator * Adapt InterfaceFileGenerator to FileGenerator * Adapt FragmentFileGenerator to FileGenerator * Adapt InputObjectFileGenerator to FileGenerator * Adapt OperationFileGenerator to FileGenerator * Adapt SchemaFileGenerator to FileGenerator * Adapt UnionFileGenerator to FileGenerator * Add Equatable conformance to OperationDefinition * Remove render function from TemplateRenderer protocol - only in extension * Rename MockTemplate to MockFileTemplate * Add FileGenerator protocol * Move path resolver logic into FileGenerator * Add FileGenerator tests * Update SchemaModuleFileGenerator for ReferenceWrapped * Adapt ApolloCodegen to ReferenceWrapped and FileGenerator * fix: Test should match all rendered content * fix: remove equality implementation, will be synthesized instead
1607ece
to
516e911
Compare
PR 1 for #2034 - This refactor grew larger than I anticipated so I'm trying to limit the changesets and keep the PRs focused; this PR refactors the file templates to support
.none
module type..none
module type by wrapping the template in a namespace seemed simple enough until I got to having to split the header and import statements from the rest of the template body; that was complicated by each template handling the header/import statement additions.TemplateRenderer
.TemplateRenderer
is a protocol that is responsible for combining individual templates based on the target of the template and the codegen configuration. Each individual template conforming to the protocol provides the base properties and the extension handles rendering and combining templates as needed.ReferenceWrapped
. This allows us to pass around the codegen configuration struct internally without copying it each time it's passed to a new function.TemplateRenderer
andImportStatementTemplate
tests for checking the import scenarios.Note: This PR will not pass CI checks until Part 2 is merged into it.