Skip to content

Commit

Permalink
queryOptions as props on PreloadQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed May 3, 2024
1 parent e64236d commit e08acd9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ export default function Page() {
<ApolloWrapper>
<form name="test">
<PreloadQuery
options={{
query: QUERY,
context: {
delay: 100,
},
variables: {
someArgument: "query1",
},
query={QUERY}
context={{
delay: 100,
}}
variables={{
someArgument: "query1",
}}
>
{(queryRef1) => (
Expand All @@ -31,14 +29,12 @@ export default function Page() {
)}
</PreloadQuery>
<PreloadQuery
options={{
query: QUERY,
context: {
delay: 100,
},
variables: {
someArgument: "query2",
},
query={QUERY}
context={{
delay: 100,
}}
variables={{
someArgument: "query2",
}}
>
{(queryRef2) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ export default function Page({ searchParams }: { searchParams?: any }) {
return (
<ApolloWrapper>
<PreloadQuery
options={{
query: QUERY,
context: {
delay: 1000,
error: searchParams?.errorIn || undefined,
},
query={QUERY}
context={{
delay: 1000,
error: searchParams?.errorIn || undefined,
}}
>
{(queryRef) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ export default function Page({ searchParams }: { searchParams?: any }) {
return (
<ApolloWrapper>
<PreloadQuery
options={{
query: QUERY,
context: {
delay: 1000,
error: searchParams?.errorIn || undefined,
},
query={QUERY}
context={{
delay: 1000,
error: searchParams?.errorIn || undefined,
}}
>
<Suspense fallback={<>loading</>}>
Expand Down
5 changes: 2 additions & 3 deletions packages/client-react-streaming/src/PreloadQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ export type PreloadQueryOptions<TVariables, TData> = QueryOptions<
RestrictedPreloadOptions;

export function PreloadQuery<TData, TVariables extends OperationVariables>({
options,
getClient,
children,
}: {
options: PreloadQueryOptions<TVariables, TData>;
...options
}: PreloadQueryOptions<TVariables, TData> & {
getClient: () => ApolloClient<any> | Promise<ApolloClient<any>>;
children:
| ReactNode
Expand Down
4 changes: 2 additions & 2 deletions packages/client-react-streaming/src/registerApolloClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ return a new instance every time \`makeClient\` is called.
return getClient;
}

interface PreloadQueryProps<TData, TVariables> {
options: PreloadQueryOptions<TVariables, TData>;
interface PreloadQueryProps<TData, TVariables>
extends PreloadQueryOptions<TVariables, TData> {
children:
| ReactNode
| ((
Expand Down

0 comments on commit e08acd9

Please sign in to comment.