Skip to content

@Deferred property of FragmentContainer not initialized #3567

@AndreaRomani

Description

@AndreaRomani

Summary

When using @defer in nested fragment spreads, the Apollo iOS codegen tool doesn't initialize the corresponding @deferred properties in the generated Fragments struct. This issue seems to occur specifically when the @defer directive is applied to a fragment spread nested inside another fragment.

Version

1.23.0

Steps to reproduce the behavior

  • Create the following schema
type Query {
  user(id: ID!): User!
}

type User {
  id: ID!
  email: String!
  name: String!
}
  • add this query
query getUser($id: ID!) {
  user(id: $id) {
    ...UserDetail
  }
}

fragment UserDetail on User {
  id
  ...UserInfo @defer(label: "userInfo")
}

fragment UserInfo on User {
  email
  name
}
  • run the codegen with this configuration
{
  "schemaNamespace": "MySchema",
  "input": {
    "operationSearchPaths": ["./Operations/**/*.graphql"],
    "schemaSearchPaths": ["./Schema/**/*.graphql"]
  },
  "output": {
    "testMocks": {
      "none": {}
    },
    "schemaTypes": {
      "path": "./Generated",
      "moduleType": {
        "embeddedInTarget": {
          "name": "MyTarget",
          "accessModifier": "public"
        }
      }
    },
    "operations": {
      "inSchemaModule": {}
    }
  },
  "options": {
    "deprecatedEnumCases": "exclude",
    "pruneGeneratedFiles": true,
    "operationDocumentFormat": ["definition", "operationId"],
    "selectionSetInitializers": {
      "namedFragments": true
    }
  },
  "operationManifest": {
    "generateManifestOnCodeGeneration": true,
    "path": "./Generated/operationIDs.json",
    "version": "persistedQueries"
  }
}
  • the following error occurs
Image

Logs

Anything else?

No response

Metadata

Metadata

Assignees

Labels

bugGenerally incorrect behaviorcodegenIssues related to or arising from code generation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions