hooks#useQuery TypeScript Examples

The following examples show how to use hooks#useQuery. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: useGetANamespaceBySlug.tsx    From one-platform with MIT License 6 votes vote down vote up
useGetANamespaceBySlug = ({ slug }: Props): UseQueryReturn<UseGetANamespaceQuery> => {
  const query = useQuery<UseGetANamespaceQuery, Props>({
    gql: GET_A_NAMESPACE,
    variables: {
      slug,
    },
    pause: !slug,
  });

  return query;
}
Example #2
Source File: useGetANamespaceBySlug.ts    From one-platform with MIT License 6 votes vote down vote up
useGetANamespaceBySlug = ({ slug }: Props): UseQueryReturn<UseGetANamespaceQuery> => {
  const query = useQuery<UseGetANamespaceQuery, Props>({
    gql: GET_A_NAMESPACE,
    variables: {
      slug,
    },
  });

  return query;
}
Example #3
Source File: useGetNamespaceList.tsx    From one-platform with MIT License 6 votes vote down vote up
useGetNamespaceList = ({
  limit = 20,
  offset = 0,
  apiCategory,
  search,
  sortBy,
  mid,
}: Props): UseQueryReturn<UseGetNamespaceListQuery> => {
  const query = useQuery<UseGetNamespaceListQuery, Props>({
    gql: GET_NAMESPACE_LIST,
    variables: {
      limit,
      offset,
      apiCategory,
      search,
      sortBy,
      mid,
    },
  });

  return query;
}
Example #4
Source File: useGetNamespaceStats.tsx    From one-platform with MIT License 6 votes vote down vote up
useGetNamespaceStats = ({
  search,
  mid,
}: Props): UseQueryReturn<UseGetNamespaceStats> => {
  const query = useQuery<UseGetNamespaceStats, Props>({
    gql: GET_NAMESPACE_STATS,
    variables: {
      search,
      mid,
    },
  });

  return query;
}
Example #5
Source File: useGetAPISchemaFile.tsx    From one-platform with MIT License 6 votes vote down vote up
useGetApiSchemaFile = ({
  envSlug,
}: Props): UseQueryReturn<UseGetAPISchemaFileQuery> => {
  const query = useQuery<UseGetAPISchemaFileQuery, Props>({
    gql: GET_API_SCHEMA_FILE,
    variables: {
      envSlug,
    },
  });

  return query;
}
Example #6
Source File: useGetNamespaceList.tsx    From one-platform with MIT License 6 votes vote down vote up
useGetNamespaceList = ({
  limit = 10,
  search,
}: Props): UseQueryReturn<UseGetNamespaceListQuery> => {
  const searchCancelRef = useRef(new AbortController());
  const query = useQuery<UseGetNamespaceListQuery, Props>({
    gql: GET_NAMESPACE_LIST,
    variables: {
      limit,
      search,
    },
    pause: !search,
    context: useMemo(
      () => ({
        fetchOptions: () => {
          const token = window.OpAuthHelper.jwtToken;
          return {
            signal: searchCancelRef.current.signal,
            headers: { authorization: token ? `Bearer ${token}` : '' },
          };
        },
      }),
      []
    ),
  });

  useEffect(() => {
    searchCancelRef.current.abort();
  }, [search]);

  return query;
}
Example #7
Source File: useGetAPISchemaFile.tsx    From one-platform with MIT License 6 votes vote down vote up
useGetApiSchemaFile = ({
  envSlug,
}: Props): UseQueryReturn<UseGetAPISchemaFileQuery> => {
  const query = useQuery<UseGetAPISchemaFileQuery, Props>({
    gql: GET_API_SCHEMA_FILE,
    variables: {
      envSlug,
    },
  });

  return query;
}