Skip to main content

useHistory or Redirect did not render component with apollo client

Problem: call mutation from MlsForm, and redirect back to Signing page, but did not rerender todos and done docs in Signing page


Solution is use fetchPolicy: 'no-cache'


if (listingId === '') return
const result = await client.query({
query: GET_LISTING_DOCUMENTS,
variables: { listingId: listingId },
fetchPolicy: 'no-cache',
})

const {
data: { getListingDocuments },
} = result

const todos = await client.query({
query: GET_TODO_DOCUMENTS,
variables: { listingId: listingId },
fetchPolicy: 'no-cache',
})

const {
data: { getTodoDocuments },
} = todos


================================


const printPdf = async (form: PrintPdfInput) => {
printListingDocumentToPdf({
variables: {
printPdfInput: form,
},
})
.then((data: any) => {
const linkToSigning = `${url.substr(0, url.search(/mlsform?/))}signing`
history.push(linkToSigning)
})
.catch((error: any) => {
setMessage(error.message)
})
}

 

Comments

Popular posts from this blog

check variable undefined with quokka

// listingId = '', 0, null, undefined, false //let listingId if ( typeof listingId === 'undefined' ) console . log ( 'listingId is undefined' ) else console . log ( listingId ) if (!! listingId ) console . log ( listingId ) else console . log ( 'listingId does not found' ) if ( listingId ) console . log ( listingId ) else console . log ( 'listingId does not found' ) if ( listingId === undefined ) console . log ( 'listingId does not found' ) else console . log ( listingId )

apollo client v3 - clean up non-needed packages

v3: https://github.com/apollographql/apollo-client clean up: ApolloProvider useQuery, useMutation, useApolloClient Apollo Client >= 3 includes React hooks functionality out of the box. You don't need to install any additional packages. https://www.apollographql.com/docs/react/api/react/hooks/ //import { ApolloProvider } from '@apollo/react-hooks' import { ApolloProvider } from '@apollo/client/react' //import { useQuery, useMutation, useApolloClient } from '@apollo/react-hooks' import { useQuery, useMutation, useApolloClient } from '@apollo/client' How i can CATCH any error (network and graphql), and prevent promise.reject()  https://github.com/apollographql/apollo-client/issues/6469 npm uninstall @apollo/react-hooks https://github.com/apollographql/apollo-link npm uninstall apollo-link npm uninstall apollo-client npm uninstall apollo-link-error npm uninstall apollo-link-http npm uninstall apollo-link-ws npm uninstall apollo-cache-inmemory