How to use the graphql-hooks.useManualQuery function in graphql-hooks

To help you get started, weโ€™ve selected a few graphql-hooks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nearform / graphql-hooks / examples / typescript / src / App.tsx View on Github external
function Post() {
  const [id, setId] = useState('')
  const [getPosts, { error, data }] = useManualQuery(postQuery)

  async function handleSubmit(e: any) {
    e.preventDefault()
    await getPosts({ variables: { id } })
  }

  return (
    <>
      <h2>Search by ID</h2>
      <form>
        <label>ID:</label>
        <input required="" value="{id}"> setId(e.currentTarget.value)}</form>
github datenguide / datenguide / src / pages / statistics / useSearchManager.js View on Github external
const useSearchManager = (initialMeasures, initialRegions) => {
  const [fetchSchema] = useManualQuery(SCHEMA_QUERY)
  const [fetchRegion] = useManualQuery(REGION_QUERY)

  const asyncActions = useMemo(
    () => ({
      syncUrl: () => async (dispatch, getState) => {
        Router.push({
          pathname: '/statistics',
          query: stateToQueryArgs(getState())
        })
      },
      loadMeasure: id => async dispatch => {
        const [statisticId, measureId] = id.split(':')
        dispatch(actions.setLoading())
        const schema = await fetchSchema({
          variables: {
            measures: [{ statisticId, measureId }]
github datenguide / datenguide / src / pages / statistics / useSearchManager.js View on Github external
const useSearchManager = (initialMeasures, initialRegions) => {
  const [fetchSchema] = useManualQuery(SCHEMA_QUERY)
  const [fetchRegion] = useManualQuery(REGION_QUERY)

  const asyncActions = useMemo(
    () => ({
      syncUrl: () => async (dispatch, getState) => {
        Router.push({
          pathname: '/statistics',
          query: stateToQueryArgs(getState())
        })
      },
      loadMeasure: id => async dispatch => {
        const [statisticId, measureId] = id.split(':')
        dispatch(actions.setLoading())
        const schema = await fetchSchema({
          variables: {
            measures: [{ statisticId, measureId }]
          }
github nearform / graphql-hooks / examples / fastify-ssr / src / app / pages / HomePage.js View on Github external
function HomePage() {
  const [name, setName] = React.useState('')
  const { loading, data, error, refetch: refetchUsers } = useQuery(
    HOMEPAGE_QUERY
  )
  const [createUser] = useMutation(CREATE_USER_MUTATION)

  const [getFirstUser, { data: firstUserData }] = useManualQuery(
    GET_FIRST_USER_QUERY,
    {
      fetchOptionsOverrides: {
        method: 'GET'
      }
    }
  )

  async function createNewUser() {
    await createUser({ variables: { name } })
    setName('')
    refetchUsers()
  }

  return (
    <div></div>

graphql-hooks

Graphql Hooks

Apache-2.0
Latest version published 5 months ago

Package Health Score

79 / 100
Full package analysis