Apollo-ios: [question] Is it possible to setup reusable fragments?

Created on 7 Jun 2020  路  2Comments  路  Source: apollographql/apollo-ios

So I have just one question that I can't seem to find the solution to, is it possible to setup re-usable fragments across multiple .graphql files. Say for example, in one file called UserProfile.graphql I declare a fragment like:

fragment UserProfile on User {
  id 
  username
  profileImage
  bio
}

and in another file named MeQuery.graphql and also UpdateProfileMutation.graphql I want to reference that fragment, ideally without duplication.

So it would look a little bit like so:

query MeQuery {
  viewer {
     ...UserProfile
  }
}

and

mutation UpdateProfileMutation($input: UpdateProfileMutationInput) {
  updateProfile(input: $input) {
    viewer {
      ..UserProfile
    }
  }
}

I don't think this is possible as of now but I was hoping for some clarification

question

Most helpful comment

Yep, this is totally doable. Anywhere a fragment is defined within the module it can be reused.

All 2 comments

Yep, this is totally doable. Anywhere a fragment is defined within the module it can be reused.

That's amazing, really loving this library!

Was this page helpful?
0 / 5 - 0 ratings