apollostack

Apollo Server - Confusion about cache/datasource options

筅森魡賤 提交于 2019-12-21 05:23:05
问题 The docs (https://www.apollographql.com/docs/apollo-server/features/data-sources.html#Using-Memcached-Redis-as-a-cache-storage-backend) show code like this: const { RedisCache } = require('apollo-server-cache-redis'); const server = new ApolloServer({ typeDefs, resolvers, cache: new RedisCache({ host: 'redis-server', // Options are passed through to the Redis client }), dataSources: () => ({ moviesAPI: new MoviesAPI(), }), }); I was wondering how that cache key is used, considering it seems

GraphQL mutation that accepts an array of dynamic size and common scalar types in one request

谁说我不能喝 提交于 2019-12-20 10:30:14
问题 I need to be able to create a user and add it's favourite movies (An array of objects with a reference to the Movies collection and his personal rating for each movie) in a single request. Something that could look like this (pseudocode) var exSchema = ` type Mutation { addUser( name: String! favMovies: [{ movie: String! #ref to movies coll personal_rating: Int! # this is different for every movie }] ) : User } ... ` What is the graphql way of doing this in a single request? I know I can

Apollo: data / mutation prop not passed to component

随声附和 提交于 2019-12-10 21:06:18
问题 I have the following component with a query and a mutation, but my Component does not receive the data and the mutation prop. Am I doing something wrong or missing in my code? The query does get executed though, it's just not passed down. this.props.mutate as well as this.props.data is undefined. class ResetConfirm extends React.Component { static propTypes = { intl: intlShape.isRequired, token: React.PropTypes.string, data: React.PropTypes.shape({ loading: React.PropTypes.bool.isRequired,

Apollo Server - Confusion about cache/datasource options

房东的猫 提交于 2019-12-03 16:43:33
The docs ( https://www.apollographql.com/docs/apollo-server/features/data-sources.html#Using-Memcached-Redis-as-a-cache-storage-backend ) show code like this: const { RedisCache } = require('apollo-server-cache-redis'); const server = new ApolloServer({ typeDefs, resolvers, cache: new RedisCache({ host: 'redis-server', // Options are passed through to the Redis client }), dataSources: () => ({ moviesAPI: new MoviesAPI(), }), }); I was wondering how that cache key is used, considering it seems like the caching is actually custom implemented in something like MoviesAPI() and then used via

updateQueries after GraphQL mutation not working with the Apollo client

旧巷老猫 提交于 2019-12-01 20:25:51
After I'm sending a createMessage mutation in my app, I want to update the local ApolloStore using updateQueries . My setup looks as follows: const ChatWithAllMessages = graphql(allMessages, {name: 'allMessagesQuery'})(Chat) export default graphql(createMessage, { props({ownProps, mutate}) { return { createMessageMutation(text, conversationId) { return mutate({ variables: { text, conversationId }, updateQueries: { allConversations: (previousState, {mutationResult}) => { console.log('Chat - did send mutation for allConversationsQuery: ', previousState, mutationResult) return ... } } }) } } } })

Apollo GraphQL React - how to query on click?

 ̄綄美尐妖づ 提交于 2019-11-27 00:17:21
问题 In the Apollo React docs http://dev.apollodata.com/react/queries.html#basics there are examples of fetching automatically when the component is shown, but I'd like to run a query when a button is clicked. I see an example to "re"fetch a query when a button is clicked, but I don't want it to query initially. I see there is a way to call mutations, but how do you call queries? 回答1: You can do it by passing a reference to Apollo Client using the withApollo higher-order-component, as documented