import { OperationVariables, QueryHookOptions, useQuery } from '@apollo/client'; import classNames from 'classnames'; import { DocumentNode } from 'graphql'; import { ReactNode } from 'react'; interface PageQueryContainerProps { query: DocumentNode; options?: QueryHookOptions; children: (data: TData) => ReactNode; } export const PageQueryContainer = ({ query, options, children, }: PageQueryContainerProps) => { const { data, loading, error } = useQuery(query, options); const splashClasses = classNames( 'w-full h-full', 'flex items-center justify-center' ); if (loading || !data) { return
Loading...
; } if (error) { return (
Something went wrong: {error.message}
); } return <>{children(data)}; };