@apollo/client#QueryOptions TypeScript Examples

The following examples show how to use @apollo/client#QueryOptions. 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: CGraphQLClient.ts    From Cromwell with MIT License 6 votes vote down vote up
/**
     * Make a custom query via ApolloClient
     * @param path query name. Used to return data, if it's not provided
     * ApolloQueryResult will be returned
     */
    public async query(options: QueryOptions, path?: string) {
        await this.checkUrl();

        const res = await this.handleError(() => this.apolloClient.query(options))
        if (path) return this.returnData(res, path);
        return res;
    }
Example #2
Source File: useUserTableDataCallback.tsx    From bouncecode-cms with GNU General Public License v3.0 6 votes vote down vote up
useUserTableDataCallback = (
  options: Partial<QueryOptions<OperationVariables>> = {},
) => {
  const client = useApolloClient();
  // const { enqueueSnackbar } = useSnackbar();

  return useCallback<ITableDataCallback>(async query => {
    const {data} = await client.query<UsersQuery>({
      ...options,
      query: UsersDocument,
      variables: {
        ...options.variables,
        take: query.pageSize,
        skip: query.page * query.pageSize,
      },
      // onError: (e) => {
      //   console.error(e);
      //   enqueueSnackbar(e.message, { variant: "error" });
      // },
    });

    console.log(data?.users);

    return {
      data: data?.users.map(user => ({...user})) || [],
      page: query.page,
      totalCount: 100, // TODO: totalCount
    };
  }, []);
}
Example #3
Source File: CGraphQLClient.ts    From Cromwell with MIT License 5 votes vote down vote up
public async query<T = any>(options: QueryOptions, path: string): Promise<T>;
Example #4
Source File: CGraphQLClient.ts    From Cromwell with MIT License 5 votes vote down vote up
public async query<T = any>(options: QueryOptions): Promise<ApolloQueryResult<T>>;