apollo-client

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:

Writing nested object to Apollo client cache

你。 提交于 2020-02-04 04:05:04
问题 I am trying to write a nested object to apollo cache but it it not working. Simple variables writes are working fine. I am using Apollo-client v2.4 // Schema const GET_DATA_FROM_CACHE = gql ` name address age ` // Reading data from cache render() { return ( <Query query = {GET_DATA_FROM_CACHE} fetchPolicy = {"cache-only"}> {({ data }) => ( <View > <Text> Name: {data.name} </Text> </View> )} </Query> ) } // THIS WORKS as I can see the name in my Text field client.writeData({ data: { name: 'mr

Writing nested object to Apollo client cache

落花浮王杯 提交于 2020-02-04 04:04:41
问题 I am trying to write a nested object to apollo cache but it it not working. Simple variables writes are working fine. I am using Apollo-client v2.4 // Schema const GET_DATA_FROM_CACHE = gql ` name address age ` // Reading data from cache render() { return ( <Query query = {GET_DATA_FROM_CACHE} fetchPolicy = {"cache-only"}> {({ data }) => ( <View > <Text> Name: {data.name} </Text> </View> )} </Query> ) } // THIS WORKS as I can see the name in my Text field client.writeData({ data: { name: 'mr

GraphQL - variable not defined by operation

ぃ、小莉子 提交于 2020-01-30 06:38:29
问题 My GraphQL schema is defined as: type Query { getEntity(id: Int!): Entity getEntityUsers(entityId: Int!, statusId: Int): [User] } type Entity { id: Int! name: String! email: String! logo: String createdAt: DateTime! updatedAt: DateTime! users(statusId: Int): [User] } As you can see I have two ways of getting users for an Entity object. The one that is currently working for my query is the getEntityUsers root resolver method. This query looks like this: query getEntityUsers($entityId: Int!,

How to use a Condition for a nested relation GQL

半世苍凉 提交于 2020-01-26 04:02:25
问题 I would like to be able to filter all of the awards by using a condition on the artist as shown below.The idea here is that I can then filter on multiple facets. By artist name, by event name/date and by categories in one query. query { allAwards { edges { node { nodeId categoryByCategoryId {} eventByEventId {} artistByArtistId(condition:{firstname:"Juan"}) {} } } } } Is there a way to do a condition/filter on the artistByArtistId/categoryByCategoryId/eventByEventId that will only return

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 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

Is it possible to prevent `useLazyQuery` queries from being re-fetched on component state change / re-render?

送分小仙女□ 提交于 2020-01-22 14:52:09
问题 Currently I have a useLazyQuery hook which is fired on a button press (part of a search form). The hook behaves normally, and is only fired when the button is pressed. However, once I've fired it once, it's then fired every time the component re-renders (usually due to state changes). So if I search once, then edit the search fields, the results appear immediately, and I don't have to click on the search button again. Not the UI I want, and it causes an error if you delete the search text