# How to initialise inline fragments manually?

**URL:** <https://community.apollographql.com/t/how-to-initialise-inline-fragments-manually/8094>\
**Category:** Client SDKs\
**Tags:** client, mobile, ios\
**Created:** [January 15, 2025, 8:47am UTC](https://community.apollographql.com/t/how-to-initialise-inline-fragments-manually/8094 "2025-01-15T08:47:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![akshaymantasolutions](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/akshaymantasolutions/32/4712_2.png) [@akshaymantasolutions](https://community.apollographql.com/u/akshaymantasolutions)\
**Post date:** [January 15, 2025, 8:47am UTC](https://community.apollographql.com/t/how-to-initialise-inline-fragments-manually/8094/1 "2025-01-15T08:47:06Z")

</div>

I am trying to initiate inline fragments manually due to some api requirements like below.

`let details = BalanceHistoryQuery.Data.Me.BalanceHistoryEvents.Edge.Node.Details(_dataDict: node.details.__data)`

But details object has one inline fragment that is not getting initialised apart from that every field has value. for example: “\_\_typename” has value.

This is details Apollo object

 ![image](https://us1.discourse-cdn.com/flex019/uploads/apollographql/original/2X/3/3eaabc4df9fd6750647d33bac99d0e091ad02e26.jpeg)

I am using 1.16 Apollo iOS.

I used to do it like this in Apollo 0.5  
`let details = BalanceHistoryQuery.Data.Me.BalanceHistoryEvent.Edge.Node.Detail(unsafeResultMap: node.details.resultMap)`

---

<div class="post-metadata">

**Author:** ![AnthonyMDev](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/anthonymdev/32/5972_2.png) [@AnthonyMDev](https://community.apollographql.com/u/AnthonyMDev)\
**Post date:** [January 16, 2025, 7:14pm UTC](https://community.apollographql.com/t/how-to-initialise-inline-fragments-manually/8094/2 "2025-01-16T19:14:47Z")

</div>

I would need to see more of your code in order to know exactly what is going on here. But for more context on how this works, when using the unsafe `init(_dataDict:)` initializer, the fragments themselves aren’t actually “initialized”. The inline fragment accessors use the `_asInlineFragment()` function to determine if their data can be converted to a given fragment type, and if so, initializes and returns the inline fragment at that time.

The `DataDict` object keeps track of which fragments are fulfilled for the object using the `DataDict._fulfilledFragments` property. This is computed and set during the GraphQL execution step, which converts a network response into the generated model objects. The logic to determine which fragments are fulfilled is complicated, but primarily it looks at the `__typename` of the data and compares that against the known schema types to determine if the underlying type should have that fragment fulfilled (ie. does the type conform to the interface or match the concrete type of the fragment).

In this case, it seems you are initializing one model by passing it the `__data` of another model. Even if the model contains all of the fields necessary to fulfill the fragment you want, if it’s `DataDict` does not contain that type in it’s `_fulfilledFragments` list, you won’t be able to convert to that fragment using the `as{{MyFragmentName}}` property.

I hope that points you in the right direction. I’d also note that, depending on your use case and what you are trying to achieve here, using our [generated selection set initializers](https://www.apollographql.com/docs/ios/code-generation/codegen-configuration#selection-set-initializers) may be a better approach.
