apollo-client

Apollo Link response headers

亡梦爱人 提交于 2020-06-10 13:45:30
问题 I am using the latest version of Apollo Client in a simple React app and I am trying to pull out a header value from the response that is being used to show the size of the record set being returned. I appreciate that this is not the most elegant way of providing the result set size, but that is how the API has currently been set up. I was hoping to use the the middleware type options to do this, but when I inspect the response object I can't seem to pull out any headers. The network trace

Custom ApolloProvider for access to React Context inside

烈酒焚心 提交于 2020-06-01 05:08:40
问题 I created ApolloCustomProvider because I want to use addNotification function from my AppContext for graphQL error handling. The problem is that this custom provider seems to work while querying or mutating API but errorLink 's functions like addNotification and console.log() doesn't work. Also console.log() from request function doesn't print anything. But when I put everything from ApolloCustomProvider to standard TypeScript file (.ts - not React Component) and then use it like: import {

Apollo react hooks array object mutation

北城余情 提交于 2020-06-01 04:44:21
问题 So I am doing a MARN stack using MongoDB, Apollo, React Native (Expo) and Node I am stuck trying to figure out how to upload an array of object. i.e A post with an array of shots It is all working fine in the Apollo playground with this: mutation createPost { createPost( input: { shots: [ { title: "Test test test" content: "Test test test" image: "https://source.unsplash.com/random/768x768" } { title: "Best best best" content: "Test test test" image: "https://source.unsplash.com/random

How do I create a GraphQL subscription with Apollo Client in Vanilla JS

旧街凉风 提交于 2020-05-28 14:45:13
问题 Recently Apollo Client released a websocket subscription feature, but so far I've only seen it used by launching a query using subscribeToMore inside the componentWillMount lifecycle hook. Here is an example taken from https://dev-blog.apollodata.com/tutorial-graphql-subscriptions-client-side-40e185e4be76#0a8f const messagesSubscription = gql` subscription messageAdded($channelId: ID!) { messageAdded(channelId: $channelId) { id text } } ` componentWillMount() { this.props.data.subscribeToMore

Auto-update of apollo client cache after mutation not affecting existing queries

人盡茶涼 提交于 2020-05-19 13:01:29
问题 I have a mutation (UploadTransaction) returning certain list of certain object named Transaction. #import "TransactionFields.gql" mutation UploadTransaction($files: [Upload!]!) { uploadFile(files: $files){ transactions { ...TransactionFields } } } Transaction returned from backend (graphene) has id and typename field. Hence it should automatically update Transaction in the cache. In chrome dev tools for Apollo, I can see new transactions: I also have a query GetTransactions fetching all

Auto-update of apollo client cache after mutation not affecting existing queries

坚强是说给别人听的谎言 提交于 2020-05-19 12:55:14
问题 I have a mutation (UploadTransaction) returning certain list of certain object named Transaction. #import "TransactionFields.gql" mutation UploadTransaction($files: [Upload!]!) { uploadFile(files: $files){ transactions { ...TransactionFields } } } Transaction returned from backend (graphene) has id and typename field. Hence it should automatically update Transaction in the cache. In chrome dev tools for Apollo, I can see new transactions: I also have a query GetTransactions fetching all

How can one upload an image to a KeystoneJS GraphQL endpoint?

末鹿安然 提交于 2020-05-17 07:01:34
问题 I'm using TinyMCE in a custom field for the KeystoneJS AdminUI, which is a React app. I'd like to upload images from the React front to the KeystoneJS GraphQL back. I can upload the images using a REST endpoint I added to the Keystone server -- passing TinyMCE an images_upload_handler callback -- but I'd like to take advantage of Keystone's already-built GraphQL endpoint for an Image list/type I've created. I first tried to use the approach detailed in this article, using axios to upload the

How can i run one mutation multiple times with different arguments in one request?

人盡茶涼 提交于 2020-03-16 09:00:23
问题 I have a mutation: const createSomethingMutation = gql` mutation($data: SomethingCreateInput!) { createSomething(data: $data) { something { id name } } } `; How do I create many Something s in one request? Do I need to create a new Mutation on my GraphQL server like this: mutation { addManySomethings(data: [SomethingCreateInput]): [Something] } Or is there a way to use the one existing createSomethingMutation from Apollo Client multiple times with different arguments in one request? 回答1: You

How can i run one mutation multiple times with different arguments in one request?

百般思念 提交于 2020-03-16 09:00:14
问题 I have a mutation: const createSomethingMutation = gql` mutation($data: SomethingCreateInput!) { createSomething(data: $data) { something { id name } } } `; How do I create many Something s in one request? Do I need to create a new Mutation on my GraphQL server like this: mutation { addManySomethings(data: [SomethingCreateInput]): [Something] } Or is there a way to use the one existing createSomethingMutation from Apollo Client multiple times with different arguments in one request? 回答1: You

@client Apollo GQL tag breaks query

眉间皱痕 提交于 2020-03-02 17:12:24
问题 I have a vue-apollo (using nuxt ) query that is supposed to have a local client field show. However, when I have the show @client line included in the query the component does not render. For some reason it also seems to fail silently. query myAccounts { accounts: myAccounts { email calendars { id name hex_color is_enabled show @client } } } I am extending the Calendar type in an extensions.js file (pasted below) with two mutations. import gql from 'graphql-tag' export const typeDefs = gql`