react-apollo

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

Snackbar not opening after Mutation

落爺英雄遲暮 提交于 2020-03-04 05:03:54
问题 I want that a snackbar opens up in case the mutation is not completely successful. In this case, handleOpen() is called. For When I hit the button, the mutation takes place and my page crashes. I get an error that TypeError: undefined is not an object (evaluating 'children.props.style') When I remove the setStatus from my handleOpen function, the page doesn't crash. Oops is printed. For Snackbar, I am using ``open={status}``` Here's my remaining code: export default function RemoveUserPage()

Typescript variable being used before assigned

早过忘川 提交于 2020-02-25 05:41:26
问题 As per instructions followed here, I'm trying to cache my endpoint URL and token from Auth0 before constructing my Apollo client: import React from 'react'; import { ApolloClient, ApolloProvider, from, HttpLink, InMemoryCache } from '@apollo/client'; import { setContext } from '@apollo/link-context'; import { useAuth0 } from './auth/AuthContext'; const App: React.FC = () => { const { isLoading, getTokenSilently, getIdTokenClaims } = useAuth0(); if (isLoading) return <Loader />; let endpoint:

Typescript variable being used before assigned

家住魔仙堡 提交于 2020-02-25 05:40:05
问题 As per instructions followed here, I'm trying to cache my endpoint URL and token from Auth0 before constructing my Apollo client: import React from 'react'; import { ApolloClient, ApolloProvider, from, HttpLink, InMemoryCache } from '@apollo/client'; import { setContext } from '@apollo/link-context'; import { useAuth0 } from './auth/AuthContext'; const App: React.FC = () => { const { isLoading, getTokenSilently, getIdTokenClaims } = useAuth0(); if (isLoading) return <Loader />; let endpoint:

How do you dynamically control react apollo-client query initiation?

好久不见. 提交于 2020-01-30 19:54:32
问题 A react component wrapped with an apollo-client query will automatically initiate a call to the server for data. I would like to fire off a request for data only on a specific user input. You can pass the skip option in the query options - but this means the refetch() function is not provided as a prop to the component; and it appears that the value of skip is not assessed dynamically on prop update. My use is case is a map component. I only want data for markers to be loaded when the user

Apollo Subscription Resolver Never Activates?

旧街凉风 提交于 2020-01-25 23:55:47
问题 My component is calling a subscription query, but for some reason the subscription resolver isn't being accessed: a breakpoint in it is never activated . And yet on the client I get the GraphQL subscription error: "Subscription must return Async Iterable. Received: undefined" What could be causing this? Thanks in advance to all for any info. SUBSCRIPTION QUERY const IM_SUBSCRIPTION_QUERY = gql` subscription getIMsViaSubscription($fromID: String!, $toID: String!){ IMAdded(fromID:$fromID, toID:

Apollo loading is always false on props change

自作多情 提交于 2020-01-25 06:42:17
问题 I am new to Apollo. Issue i am facing is that On initial (Mount/Render) network call is made and on prop change it isn't. Following is simplified structure of my application. <Component (has filters in state)> <QueryComponent filters = {...filters} (passed to query)> <Table onChange/> </QueryComponent> <Component/> QueryComponent Code export const QueryComponent = ({ callback, filter }) => { // Data transformation from filter to vars(expected by Query) return ( <Query handleLoading query=

Apollo Client: Network Error {“type”:“WriteError”}

给你一囗甜甜゛ 提交于 2020-01-24 22:42:09
问题 I am getting Network Error {"type":"WriteError"} on my apollo query. Query executes just fine as well as it arrives to the client. But there is issue writing it tot he store. Any ides what can be going wrong? This is the query: fragment BpmnProcessInstanceItemTask on BpmnTaskInstance { id dateStarted dateFinished task { name __typename } performer { name __typename } performerRoles __typename } fragment BpmnProcessInstanceItem on BpmnProcessInstance { id status process { name description type

Handling errors with react-apollo useMutation hook

与世无争的帅哥 提交于 2020-01-24 18:56:51
问题 I have been trying to get my head around this problem but haven't found a strong answer to it. I am trying to execute a login mutation using the useMutation hook. TLDR; I want to know what exactly is the difference between the onError passed in options and error given to me by the useMutation Here's my code snippet const [login, { data, loading, error }] = useMutation(LOGIN_QUERY, { variables: { email, password }, onError(err) { console.log(err); }, }); On the server-side, I have a preset