How to use the @apollo/react-hooks.useLazyQuery function in @apollo/react-hooks

To help you get started, we’ve selected a few @apollo/react-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 dailykit / react-file-manager / src / components / Grid / Card / index.jsx View on Github external
appearance: 'success',
				autoDismiss: true,
			})
		},
		refetchQueries: [refetchOptions],
	})
	const [renameFolder] = useMutation(RENAME_FOLDER, {
		onCompleted: ({ renameFolder }) => {
			addToast(renameFolder.message, {
				appearance: 'success',
				autoDismiss: true,
			})
		},
		refetchQueries: [refetchOptions],
	})
	const [openFileQuery] = useLazyQuery(OPEN_FILE, {
		onCompleted: () => {
			addToast('Opened file in editor!', {
				appearance: 'success',
				autoDismiss: true,
			})
		},
	})

	const openFile = () => {
		openFileQuery({
			variables: {
				path: item.path,
			},
		})
	}
github connect-foundation / 2019-13 / front / src / Routes / Details.js View on Github external
const Detail = ({ match, history }) => {
  const [user, setUser] = useState();
  const [project, setProject] = useState();
  const [isLiked, setIsLiked] = useState();
  const [addView] = useMutation(ADD_VIEW);
  const [likeCount, setLikeCount] = useState();
  const [ready, setReady] = useState(false);
  const [me] = useLazyQuery(ME, {
    onCompleted(res) {
      if (res.me) {
        setUser(res.me);
      }
    },
  });

  const [loadProject] = useLazyQuery(LOAD_PROJECT, {
    onCompleted(res) {
      if (!res.findProjectById) {
        history.goBack();
      } else {
        const projectData = res.findProjectById;
        setProject(res.findProjectById);
        setIsLiked(res.findProjectById.isLiked);
        setLikeCount(res.findProjectById.likeCount);
        images = [];
        const render = workspaceList.workspaces[0].setRender;
        workspaceList.workspaces = [];
        workspaceList.images = [];
        workspaceList.dropdownItems.sprite = { wall: '벽' };
        projectData.workspaces.forEach((ws) => {
          const newWorkSpace = new Workspace({
            setRender: render, id: ws.id, imageId: ws.images[0].id,
github penta-jelly / re-radio / client / src / operations / index.tsx View on Github external
export function useCurrentUserLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHookOptions) {
          return ApolloReactHooks.useLazyQuery(CurrentUserDocument, baseOptions);
        }
export type CurrentUserQueryHookResult = ReturnType;
github agoldis / sorry-cypress / packages / dashboard / src / generated / graphql.ts View on Github external
export function useGetRunsFeedLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHookOptions) {
          return ApolloReactHooks.useLazyQuery(GetRunsFeedDocument, baseOptions);
        }
export type GetRunsFeedQueryHookResult = ReturnType;
github karanpratapsingh / Proximity / app / screens / MessageScreen / index.tsx View on Github external
const MessageScreen: React.FC = () => {

  const { navigate } = useNavigation();
  const { user, theme } = useContext(AppContext);

  const [queryChats, { called, data, loading, error }] = useLazyQuery(QUERY_CHATS, {
    variables: { userId: user.id },
    fetchPolicy: 'network-only',
    pollInterval: PollIntervals.messages
  });

  const [createTemporaryChat] = useMutation(MUTATION_CREATE_TEMPORARY_CHAT);

  const [chatSearch, setChatSearch] = useState('');
  const newMessageBottomSheetRef = useRef();

  useEffect(() => {
    queryChats();
  }, []);

  const renderItem = ({ item }) => {
github NoQuarterTeam / fullstack-boilerplate / packages / web / src / lib / graphql / types.tsx View on Github external
export function useMeLazyQuery(
  baseOptions?: ApolloReactHooks.LazyQueryHookOptions<
    MeQuery,
    MeQueryVariables
  >,
) {
  return ApolloReactHooks.useLazyQuery(
    MeDocument,
    baseOptions,
  )
}
github copenhagenjs / copenhagenjs.dk / web / pages / index.js View on Github external
const [token, setToken] = useState('')
  const [attendance, setAttendance] = useState('INIT')
  const [attendEvent, { attendEventData }] = useMutation(ATTEND_EVENT, {
    context: {
      headers: {
        authorization: 'bearer ' + token
      }
    },
    onCompleted(data) {
      if (data.attendEvent.status) {
        setAttendance(data.attendEvent.status)
      }
    }
  })
  const { loading, error, data } = useQuery(EVENTS)
  const [getAttendanceStatus, attendanceMeta] = useLazyQuery(ATTENDING, {
    context: {
      headers: {
        authorization: 'bearer ' + token
      }
    },
    onCompleted(data) {
      if (
        data.upcoming &&
        data.upcoming.length !== 0 &&
        data.upcoming[0].attendance
      ) {
        setAttendance(data.upcoming[0].attendance.status)
      }
    }
  })
github connect-foundation / 2019-03 / web / src / containers / UserPage / UserPageInfo / UserInfo / CountIndicator / index.js View on Github external
const FOLLOW_LIST = gql`
    query FollowList($myId: Int!, $userId: Int!) {
      followList(myId: $myId, userId: $userId) {
        id
        name
        username
        profileImage
        isFollow
      }
    }
  `;
  const lazyQueryOption = {
    variables: { myId, userId: data.id },
    fetchPolicy: 'cache-and-network',
  };
  const [loadFollowerList, followerResult] = useLazyQuery(
    FOLLOWER_LIST,
    lazyQueryOption,
  );
  const [loadFollowList, followResult] = useLazyQuery(
    FOLLOW_LIST,
    lazyQueryOption,
  );

  const [isFollowerModalVisible, setIsFollowerModalVisible] = useState(false);
  const [isFollowModalVisible, setIsFollowModalVisible] = useState(false);

  const onFollowerClick = async () => {
    await loadFollowerList();
    setIsFollowerModalVisible(curVisibleState => !curVisibleState);
  };
  const onFollowClick = async () => {
github zerosoul / github-star-stats / src / hooks / useStars.js View on Github external
export default function useStars() {
  const [loading, setLoading] = useState(false);
  const [finished, setFinished] = useState(false);
  const [repo, setRepo] = useState(null);
  const [data, setData] = useState(undefined);
  const [loadStars, { called, data: pageData, variables, error }] = useLazyQuery(GetStars);

  useEffect(() => {
    if (pageData) {
      setLoading(true);
      const { stargazers } = pageData.repository;
      const { edges, totalCount } = stargazers;
      const { hasNextPage, endCursor } = stargazers.pageInfo;
      setData((oldData = {}) => {
        const tmpObj = {};
        edges.forEach(({ node, starredAt }) => {
          let dateObj = new Date(starredAt);
          let keyVal = `${dateObj.toLocaleDateString(navigator.language, {
            month: '2-digit',
            day: '2-digit',
            year: 'numeric'
          })}`;
github wendelfreitas / animavita / packages / mobile / src / pages / Localization / index.js View on Github external
actions: [NavigationActions.navigate({ routeName: 'SignedIn' })],
      });
      navigation.dispatch(resetAction);
    },
    onError: () => {
      showMessage({
        message: 'Erro ao buscar sua localização!',
        description:
          'Ops! Você acredita que o gatinho quase quebrou o GPS? Tente liga-lo novamente.',
        type: 'danger',
      });
      setLoading(false);
    },
  });

  const [getLocalization] = useLazyQuery(GET_LOCALIZATION, {
    onCompleted: ({ localization }) => {
      setLocalization(localization);
      setLoading(false);
    },
  });

  function getLocation() {
    setLoading(true);
    Geolocation.getCurrentPosition(
      (position) => {
        const { coords } = position;
        getLocalization({
          variables: {
            latitude: coords.latitude,
            longitude: coords.longitude,
          },