apollo

How do you type partial types in a TypeScript Angular application using an Apollo backend?

六眼飞鱼酱① 提交于 2019-12-23 02:29:15
问题 Edit: I'm looking for an authority and sourced answer from Graphql-Angular community to provide a best practice example. For example, we have a Person type defined as such in TypeScript: interface Person { firstName: string; lastName: string; birthDate: Date; age: number; ...and many more attributes } Let's say you have a component, and in accordance to the graphql mantra, you only fetch what you need. No overfetching and underfetching. I only need the Person 's firstName and age , so I make

Apollo updateQueries Not Called?

孤街浪徒 提交于 2019-12-22 14:59:48
问题 I'm studying Apollo pub-sub in GitHunt-React and GitHunt-API. When I run those apps and enter a new comment, the comment is saved by the call to submit, and then the updateQueries codeblock runs here: const CommentsPageWithMutations = graphql(SUBMIT_COMMENT_MUTATION, { props({ ownProps, mutate }) { console.log('in CommentsPageWithMutations'); return { submit({ repoFullName, commentContent }) { <==RUNS THE MUTATION debugger; return mutate({ variables: { repoFullName, commentContent },

How to get updated data from apollo cache

空扰寡人 提交于 2019-12-22 08:17:46
问题 Does Apollo client have some sort of thing like mapStateToProps (Redux)? let's say I have a component, after query I know there's data in the cache so I do something like: class Container extends React.Component { ... ... render() { const notes = this.props.client.readFragment(NOTES_FRAGMENT) // notes has everything I need return (<Child notes={notes} />); } } export default WithApollo(Container); However when I have a sibling component which calls mutation and do update, the <Child />

Apollo Query with Variable

馋奶兔 提交于 2019-12-22 04:59:11
问题 Just a basic apollo query request this.client.query({ query: gql` { User(okta: $okta){ id } }` }).then(result => { this.setState({userid: result.data.User}); console.log(this.state.userid.id) }).catch(error => { this.setState({error: <Alert color="danger">Error</Alert>}); }); The question is, how/where to set the $okta variable. Didn't find a solution on Stackoverflow or Google - would be great if someone could help me:) 回答1: It should be something like this: const query = gql` query User(

Apollo - update() method getting called twice, both times with optimistic/fake data

吃可爱长大的小学妹 提交于 2019-12-21 07:13:17
问题 I'm completely stuck on an Apollo problem, for which I've opened a GitHub issue and had zero response on. I'm calling an Apollo mutation, using optimisticResponse . The way it's supposed to work, as I understand it, is that update() gets called twice: first with the optimistic data, then again with the actual data coming in from the network. But for some reason, my code is not working like this. I'm getting two update() calls, both with the optimistic data. Here's a repo that demonstrates

Apollo Server - Confusion about cache/datasource options

佐手、 提交于 2019-12-21 05:23:13
问题 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

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

Missing selection set for object GraphQL+Apollo error

混江龙づ霸主 提交于 2019-12-21 04:18:25
问题 I have a set of mutations that trigger the local state of certain types of popups. They're generally set up like this: openDialog: (_, variables, { cache }) => { const data = { popups: { ...popups, dialog: { id: 'dialog', __typename: 'Dialog', type: variables.type } } }; cache.writeData({ data: data }); return null; } And the defaults I pass in look like: const defaults = { popups: { __typename: TYPENAMES.POPUPS, id, message: null, modal: null, menu: null, dialog: null } }; The way they're

Apollo GraphQL keeps reloading in console with no query or mutation make

僤鯓⒐⒋嵵緔 提交于 2019-12-20 05:20:17
问题 I was learning GraphQL and about to finish the tutorial and this never happened before. The problem is, GraphQL server keeps reloading in console after opening GraphQL playground in browser with no query or mutation. Here's the screencast: https://i.imgur.com/k842tf1.gifv AS you can see, console on left side keeps reloading. Here are some of the logs that I suspect: { "name":"deprecated", "description":"Marks an element of a GraphQL schema as no longer supported.", "locations":[ "FIELD

Apollo Client Write Query Not Updating UI

拜拜、爱过 提交于 2019-12-19 09:42:15
问题 We are building an offline first React Native Application with Apollo Client. Currently I am trying to update the Apollo Cache directly when offline to update the UI optimistically. Since we offline we do not attempt to fire the mutation until connect is "Online" but would like the UI to reflect these changes prior to the mutation being fired while still offline. We are using the readQuery / writeQuery API functions from http://dev.apollodata.com/core/read-and-write.html#writequery-and