Skip to content
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

feature(defer): Code generation #219

Conversation

calvincestari
Copy link
Member

@calvincestari calvincestari commented Jan 3, 2024

This PR adds the missing pieces to codegen for the @defer implementation:

  1. Deferred fragment metadata - this metadata is needed to support incremental parsing which needs to be able to link a deferred selection set to a defer label received in each incremental response.
  2. Operations that use @defer on a named fragment - the template changes in this draft PR at the moment only solve for simple named fragment use cases in order to ready for a preview release. As I add the test cases I'll resolve for all use cases of deferred named fragments.

There are no tests included with this PR yet, they're still coming

@@ -538,13 +568,22 @@ struct SelectionSetTemplate {
let isOptional =
fragment.inclusionConditions != nil
&& !scope.matches(fragment.inclusionConditions.unsafelyUnwrapped)
let isDeferred = fragment.typeInfo.deferCondition != nil

return """
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might be at the point where it makes sense to break this function into smaller focused functions.

@@ -18,7 +18,7 @@ public class NamedFragmentSpread: Hashable, CustomDebugStringConvertible {
/// Indicates the location where the fragment has been "spread into" its enclosing
/// operation/fragment. It's `scopePath` and `entity` reference are scoped to the operation it
/// belongs to.
let typeInfo: SelectionSet.TypeInfo
public let typeInfo: SelectionSet.TypeInfo
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason this shouldn't be a public constant? Doing so matches what we make available on InlineFragment and means we don't need to have a public method just to get at deferCondition. The type info is also used in the deferred fragment metadata template, but that may change.

@calvincestari calvincestari force-pushed the defer/oustanding-defer-codegen branch from a5fa3e9 to 58a7894 Compare February 6, 2024 19:46
Copy link

@Karliz24 Karliz24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


@calvincestari
Copy link
Member Author

Base automatically changed from defer/partial-and-incremental-execution to feature/defer-execution-networking March 19, 2024 23:30
…ing-defer-codegen

# Conflicts:
#	Tests/ApolloCodegenTests/CodeGenIR/IRRootFieldBuilderTests.swift
#	Tests/ApolloTests/GraphQLResultTests.swift
#	Tests/ApolloTests/Interceptors/IncrementalJSONResponseParsingInterceptorTests.swift
#	Tests/ApolloTests/Interceptors/MultipartResponseDeferParserTests.swift
#	apollo-ios-codegen/Sources/ApolloCodegenLib/Templates/SelectionSetTemplate.swift
#	apollo-ios/Sources/Apollo/AnyGraphQLResponse.swift
#	apollo-ios/Sources/Apollo/GraphQLResult.swift
#	apollo-ios/Sources/Apollo/IncrementalGraphQLResponse.swift
#	apollo-ios/Sources/Apollo/IncrementalJSONResponseParsingInterceptor.swift
#	apollo-ios/Sources/Apollo/MultipartResponseDeferParser.swift
#	apollo-ios/Sources/ApolloAPI/GraphQLOperation.swift
@calvincestari
Copy link
Member Author

@calvincestari calvincestari deleted the defer/oustanding-defer-codegen branch April 4, 2024 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Complete test cases for selection set template
2 participants