Skip to content

Commit

Permalink
Squashed 'apollo-ios-codegen/' changes from 57e9a92d..45b05486
Browse files Browse the repository at this point in the history
45b05486 Fixing fragment definition generation when not generating operation definitions (#218)

git-subtree-dir: apollo-ios-codegen
git-subtree-split: 45b054866bb3307b3b941dcf62dff144a706599c
  • Loading branch information
gh-action-runner authored and gh-action-runner committed Jan 16, 2024
1 parent 7dacff1 commit e7e5c59
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Sources/ApolloCodegenLib/Templates/FragmentTemplate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,20 @@ struct FragmentTemplate: TemplateRenderer {
func renderBodyTemplate(
nonFatalErrorRecorder: ApolloCodegen.NonFatalError.Recorder
) -> TemplateString {
let includeDefinition = config.options.operationDocumentFormat.contains(.definition)

return TemplateString(
"""
\(accessControlModifier(for: .parent))\
struct \(fragment.generatedDefinitionName.asFragmentName): \
\(fragment.renderedSelectionSetType(config)), Fragment {
\(if: includeDefinition, """
\(accessControlModifier(for: .member))\
static var fragmentDefinition: StaticString {
#"\(fragment.definition.source.convertedToSingleLine())"#
}
""")
\(SelectionSetTemplate(
definition: fragment,
generateInitializers: config.options.shouldGenerateSelectionSetInitializers(for: fragment),
Expand Down

0 comments on commit e7e5c59

Please sign in to comment.