Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

getOperationFieldName should ignore FragmentDefinition #878

Closed
AnderLuiz opened this issue Oct 1, 2020 · 2 comments
Closed

getOperationFieldName should ignore FragmentDefinition #878

AnderLuiz opened this issue Oct 1, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@AnderLuiz
Copy link

Bug Report

Hi,

updateQuery does not work when the query has a fragment.

const mutationOptions = {
        mutation: DELETE_CITY,
        variables: {
          id: item.id,
        },
        updateQuery: {
          query: ALL_CITIES,
          variables: { },
        },
        operationType: CacheOperation.DELETE,
        returnType: 'City',
        idField: 'id',
      };
      const response = await this.props.client.offlineMutate(mutationOptions);
     //...

ALL_CITIES query :

#import "../../fragments/city/city_attributes_fragment.graphql"
#import "../../fragments/city/city_belongs_to_associations_fragment.graphql"
#import "../../fragments/city/city_has_many_associations_fragment.graphql"
#import "../../fragments/city/city_quantum_fragment.graphql"

query allCities(
  $ids: [UUID]
  $name: String
  $stateId: UUID
  $order: String
  $limit: Int
  $offset: Int
) {
  allCities(
    ids: $ids
    name: $name
    stateId: $stateId
    order: $order
    limit: $limit
    offset: $offset
  ) {
    id
    ...CityAttributesFragment
    ...CityBelongsToAssociationsFragment
    ...CityHasManyAssociationsFragment
    ...CityQuantumFragment
  }
}

image

https://github.com/aerogear/offix/blob/master/packages/offix/cache/src/utils/helperFunctions.ts#L30
image

This function is returning the name from the FragmentDefinition but should get from the OperationDefinition.

image

  • Affected Package(s):
    offix-cache
  • Package version(s):
    0.16.0-beta1
  • Platform (e.g. Android/iOS): Android
@wtrocki wtrocki added the bug Something isn't working label Oct 1, 2020
@wtrocki
Copy link
Contributor

wtrocki commented Oct 1, 2020

A workaround would be to build this particular cache update yourself. I think the API for that changed in apollo 3.0 as well.

@kingsleyzissou
Copy link
Contributor

Hi @AnderLuiz, we have made the decision to move away from the Apollo client and we have decided to deprecate our Offix packages and release our Datastore. I will be closing this issue, but if you have any questions, please feel free to let us know.

You can see the docs for the updated datastore here:
https://offix.dev/docs/getting-started

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants