Hello, we are using apollo library on our mobile c...
# apollo-kotlin
a
Hello, we are using apollo library on our mobile clients (ios/android). We want to create a mutation which contains dynamic set of another mutations. But we haven’t find the right way to do that. Example query:
Copy code
mutation offlineSync {
  s1: createDeliveryShift(input: {
    id: "71ea006c-2a4d-476a-9bcc-78c43baa7bb7"
    data: {
      id: "71ea006c-2a4d-476a-9bcc-78c43baa7bb7"
    }
    registeredAt: "2020-11-05T14:11:00.000Z"
  }) {
    id
  }
  s2: startDeliveryShift(input: {
    id: "2cd03c01-c684-41f1-b1a0-aac285b29ba7"
    data: {
      id: "71ea006c-2a4d-476a-9bcc-78c43baa7bb7"
      startedAt: "2020-11-05T14:11:00.000Z"
    }
    registeredAt: "2020-11-05T14:11:00.000Z"
  }) {
    id
  }
}
amount of mutation is dynamic. in the example there is only two mutations s1,s2, but amount and type of mutations could be different. Is it possible to do that wit apollo client library?
m
Hi! That's not possible because there would be no way to generate the typesafe models at compile time if the mutation changes at runtime
I think what you're looking for is query batching. Instead of querying multiple fields in the same mutation, you define multiple mutations and send them all at once to your server:
Copy code
[
  {
    query: < query 0 >,
    variables: < variables for query 0 >,
  },
  {
    query: < query 1 >,
    variables: < variables for query 1 >,
  },
  {
    query: < query n >
    variables: < variables for query n >,
  }
]
That's not supported by apollo-android yet but we'd like to get there!
a
So, the first variant is not possible, and the second varian is not available yet?
👍 1
m
yes
a
@mbonnin Do you have any expectations when the second approach could be implemented?
m
It's always hard to tell, I'd say somewhere Q1 2021 for a first rough estimate, it's been pretty high in the wish list
We do accept contributions too! I haven't looked too much into what's going to be needed for this. The initial gut feeling is that it's not straighforward but maybe there's a smart way to do it without touching too much of the runtime
a
Ok, thank you very much. Will discuss feature actions with a team.
👍 1