How to use the react-apollo-hooks.useQuery function in react-apollo-hooks

To help you get started, we’ve selected a few react-apollo-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 phiilu / mailman / web / src / components / Account / AccountCreate / index.js View on Github external
const [account, setAccount] = useState(defaultState);
  const [submitting, setSubmitting] = useState(false);

  // GraphQL
  const createAccount = useMutation(CREATE_ACCOUNT_MUTATION, {
    refetchQueries: [
      { query: ALL_ACCOUNTS_QUERY },
      {
        query: ALL_ACCOUNTS_BY_DOMAIN_QUERY,
        variables: { domain }
      },
      { query: COUNT_QUERY },
      { query: ALL_DOMAINS_QUERY }
    ]
  });
  const { data, loading, error } = useQuery(ALL_DOMAINS_QUERY, {
    suspend: false
  });

  if (error) {
    console.log(error);
    return `Error!`;
  }

  const domains = data.domains
    ? data.domains.nodes
    : [{ id: -1, domain: "Loading ..." }];

  useEffect(
    () => {
      setAccount({ ...account, domain: domain || domains[0].domain });
    },
github NoQuarterTeam / split / packages / web / src / lib / graphql / types.tsx View on Github external
export function use(
    baseOptions?: ReactApolloHooks.QueryHookOptions,
  ) {
    return ReactApolloHooks.useQuery(Document, baseOptions)
  }
}
github mgm-interns / team-radio / client / src / RadioGraphql / RealTimeStationPlaylist / RealTimeStationPlaylistQuery.tsx View on Github external
export function useQuery(options: QueryHookOptions) {
  return ReactApolloHooks.useQuery(QUERY, options);
}
github mgm-interns / team-radio / client / src / RadioGraphql / RealTimeStation / RealTimeStationQuery.tsx View on Github external
export function useQuery(options: QueryHookOptions) {
  return ReactApolloHooks.useQuery(QUERY, options);
}
github mgm-interns / team-radio / client / src / RadioGraphql / RealTimeStations / RealTimeStationsQuery.tsx View on Github external
export function useQuery(options?: QueryHookOptions) {
  return ReactApolloHooks.useQuery(QUERY, options);
}
github mgm-interns / team-radio / client / src / RadioGraphql / RealTimeStationPlayer / RealTimeStationPlayerQuery.tsx View on Github external
export function useQuery(options: QueryHookOptions) {
  return ReactApolloHooks.useQuery(QUERY, options);
}
github Urigo / WhatsApp-Clone-Client-React / src / graphql-hooks / users-hooks.ts View on Github external
export const useGetUsers = (options?) => {
  useUserInfoChanged()

  return useQuery(getUsersQuery, options)
}
github Urigo / WhatsApp-Clone-Client-React / src / graphql-hooks / chats-hooks.ts View on Github external
export const useGetChats = (options?) => {
  useChatAdded()
  useChatInfoChanged()

  return useQuery(getChatsQuery, options)
}
github phiilu / mailman / web / src / pages / Domains / index.js View on Github external
},
      { query: COUNT_QUERY }
    ]
  });
  const updateDomain = useMutation(UPDATE_DOMAIN_MUTATION, {
    refetchQueries: [{ query: ALL_DOMAINS_QUERY }]
  });
  const deleteDomain = useMutation(DELETE_DOMAIN_MUTATION, {
    refetchQueries: [
      {
        query: ALL_DOMAINS_QUERY
      },
      { query: COUNT_QUERY }
    ]
  });
  const { data, loading, error } = useQuery(ALL_DOMAINS_QUERY, {
    suspend: false
  });

  const showEditDomainHideCeateDomain = id => {
    if (showCreateDomain) {
      setShowCreateDomain(false);
    }
    setEditDomainId(id);
    setShowEditDomain(true);
  };

  const showCreateDomainHideEditDomain = () => {
    if (showEditDomain) {
      setShowEditDomain(false);
    }
    setShowCreateDomain(true);
github spacexland / client / src / app / Ships / Ships.tsx View on Github external
export default function Launches({
  name,
  limit,
  offset,
  match,
  setTotalCount
}: RouteComponentProps & any) {
  const {
    data: {
      shipsResult: {
        data,
        result: { totalCount }
      }
    },
    error
  } = useQuery(query, {
    variables: {
      name,
      limit,
      offset
    }
  });

  setTotalCount(totalCount);

  return error ? (
    <span>{error}</span>
  ) : (
    
      {data.map(({ id, name }) =&gt; (
        <div>
          â›´ {name}</div>

react-apollo-hooks

Use [Apollo Client](https://github.com/apollographql/apollo-client) as React [hooks](https://reactjs.org/docs/hooks-intro.html).

MIT
Latest version published 5 years ago

Package Health Score

53 / 100
Full package analysis

Similar packages