react-apollo

React Apollo updating client cache after mutation

巧了我就是萌 提交于 2021-01-28 07:44:34
问题 I am trying to update my chache after succesfully executing a mutation. Here is my query and mutation: export const Dojo_QUERY = gql` query Dojo($id: Int!){ dojo(id: $id){ id, name, logoUrl, location { id, city, country }, members{ id }, disziplines{ id, name } } }`; export const addDiszipline_MUTATION = gql` mutation createDisziplin($input:DisziplineInput!,$dojoId:Int!){ createDisziplin(input:$input,dojoId:$dojoId){ disziplin{ name, id } } }`; and my mutation call: const [createDisziplin] =

Proper way of refetching queries after mutation in React + ApolloClient project

我与影子孤独终老i 提交于 2021-01-28 06:10:14
问题 Creating an app which allows you to sign up and sign in user in the database. After sign up / sign in process the app moves you to the content. Code for authorization process: const Auth = ({ handleSetAuthorized }) => { const { refetch } = useQuery(CURRENT_USER) const { error } = useSelector(({ error }) => error) const history = useHistory() const dispatch = useDispatch() const [signup] = useMutation(SIGN_UP, { onCompleted: async (data) => { const token = data.signup localStorage.setItem(

Apollo GraphQL requests are canceled

∥☆過路亽.° 提交于 2021-01-27 20:45:26
问题 I am building a React type ahead text field component using Downshift and react-apollo . As the user types I am querying type ahead suggestions and present them underneath the text field. Unfortunately, this experience is not going smoothly. For some reason every now and then Apollo cancels more than 50 percent of the requests. I am also logging the response data that is accessible to the component wrapped with the graphql HoC. In the desired case, the loading state is set to false and my

Prisma 2 query to return records only that are associated with ALL of the provided tag IDs

和自甴很熟 提交于 2021-01-04 03:25:17
问题 I have tables Principles and Tags. And there is a many-to-many relation between them (joined implicitly). Without using prisma.raw , how can I run the following query? SELECT p.id, p.title, p.description, p.createdAt, p.modifiedAt FROM principle p WHERE EXISTS (SELECT NULL FROM _PrincipleToTag pt WHERE pt.B IN (${tagIds.join(',')}) AND pt.A = p.id GROUP BY pt.A HAVING COUNT(DISTINCT pt.B) = ${tagIds.length}) How can I update this Prisma 2 query such that the principles returned are only

Prisma 2 query to return records only that are associated with ALL of the provided tag IDs

佐手、 提交于 2021-01-04 03:22:52
问题 I have tables Principles and Tags. And there is a many-to-many relation between them (joined implicitly). Without using prisma.raw , how can I run the following query? SELECT p.id, p.title, p.description, p.createdAt, p.modifiedAt FROM principle p WHERE EXISTS (SELECT NULL FROM _PrincipleToTag pt WHERE pt.B IN (${tagIds.join(',')}) AND pt.A = p.id GROUP BY pt.A HAVING COUNT(DISTINCT pt.B) = ${tagIds.length}) How can I update this Prisma 2 query such that the principles returned are only

Prisma 2 query to return records only that are associated with ALL of the provided tag IDs

我的梦境 提交于 2021-01-04 03:22:10
问题 I have tables Principles and Tags. And there is a many-to-many relation between them (joined implicitly). Without using prisma.raw , how can I run the following query? SELECT p.id, p.title, p.description, p.createdAt, p.modifiedAt FROM principle p WHERE EXISTS (SELECT NULL FROM _PrincipleToTag pt WHERE pt.B IN (${tagIds.join(',')}) AND pt.A = p.id GROUP BY pt.A HAVING COUNT(DISTINCT pt.B) = ${tagIds.length}) How can I update this Prisma 2 query such that the principles returned are only

How to correctly redirect after catching authentication failure with Apollo and React

痴心易碎 提交于 2021-01-02 05:22:17
问题 I'm writing a react app that uses apollo-client and I'm using apollo-link-error to catch authentication errors globally. I'm using createBrowserHistory for browser history manipulation and redux to manage my app state. On authentication error I want to redirect the user to the /login page. However, doing so with history.push('/login') and forceRefresh:false changes the URL but doesn't actually navigate inside my app. If I use forceRefresh:true it works, but the app is completely restarted,