menu

Apollo

A community of developers, designers and others who love Apollo and GraphQL. 🚀

Channels
# All channels
view-forward
# General
view-forward
# Apollo Angular
view-forward
# Announcements
view-forward
# Apollo Android
view-forward
# Apollo Client
view-forward
# Apollo iOS
view-forward
# Apollo Link
view-forward
# Apollo Link Rest
view-forward
# Local State
view-forward
# Apollo Studio
view-forward
# Apollo Server
view-forward
# Apollo Tooling
view-forward
# Contributing
view-forward
# Docs
view-forward
# Events
view-forward
# GraphQL Tools
view-forward
# Jobs
view-forward
# Random
view-forward
# React Apollo
view-forward
# Showcase
view-forward
# Subscriptions
view-forward
# Testing
view-forward
# Vue Apollo
view-forward
Team

Query Param in response?

October 30, 2019 at 3:07pm

Query Param in response?

October 30, 2019 at 3:07pm
Is it possible to pass a query parameter to the response? So that I can use it in the InMemoryCache dataIdFromObject key resolver.
query getSource($bodyBuilder: any, $categoryId: String!) {
response(deviceId: $deviceId, categoryId: $categoryId) @rest(
type: "Source",
path: "/sourcemix/search",
endpoint: "sources"
method: "POST",
bodyBuilder: $bodyBuilder
) {
// Here I want to use the categoryId param.
category: {args.categoryId}
name
....
...
}
}
dataIdFromObject: object => {
switch (object.__typename) {
// Now I can create a cache key based on categoryId
case 'source': return object.categoryId
// fall back to default handling
default: return defaultDataIdFromObject(object);
}
}
No messages yet