Skip to content

Commit

Permalink
Fixing fragment definition generation when not generating operation d…
Browse files Browse the repository at this point in the history
  • Loading branch information
BobaFetters authored and gh-action-runner committed Jan 16, 2024
1 parent 57e9a92 commit 45b0548
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 45b0548

Please sign in to comment.