Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

64
Views
Get parent object at field type policy

Let's say that I have the following query that fetches a list of products.

query ProductList() {
  products() {
    name
    price
    stockQuantity
    isAvailable @client # This is a local-only field
  }
}

Also I have added a type policy for a local-only field at the in-memory cache creation, with a read function:

const cache = new InMemoryCache({
  typePolicies: { // Type policy map
    Product: {
      fields: { // Field policy map for the Product type
        isAvailable: { // Field policy for the isAvailable field
          read(existing, context) { // The read function for the isAvailable field
            // Return value
          }
        }
      }
    }
  }
});

How can I get the stockQuantity field of the parent Product object at the isAvailable read function?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

const cache = new InMemoryCache({
  typePolicies: { // Type policy map
    Product: {
      fields: { // Field policy map for the Product type
        isAvailable: { // Field policy for the isAvailable field
          read(existing, {readField}) { // The read function for the isAvailable field
            const stockQuantity = readField("stockQuantity");
            return stockQuantity ? true : false;
          }
        }
      }
    }
  }
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!