apollo-fragment-react
Advanced tools
Comparing version 0.6.0 to 0.6.1
@@ -25,4 +25,9 @@ (function (global, factory) { | ||
function useApolloFragment(fragment, id) { | ||
var _a = apolloFragmentUtils.getFragmentInfo(fragment), fragmentTypeName = _a.fragmentTypeName, fragmentName = _a.fragmentName; | ||
var query = apolloFragmentUtils.buildFragmentQuery({ fragment: fragment, fragmentName: fragmentName }); | ||
var _a = React.useMemo(function () { | ||
var _a = apolloFragmentUtils.getFragmentInfo(fragment), fragmentTypeName = _a.fragmentTypeName, fragmentName = _a.fragmentName; | ||
return { | ||
query: apolloFragmentUtils.buildFragmentQuery({ fragment: fragment, fragmentName: fragmentName }), | ||
typename: fragmentTypeName, | ||
}; | ||
}, [fragment]), query = _a.query, typename = _a.typename; | ||
var _b = reactApollo.useQuery(query, { | ||
@@ -32,3 +37,3 @@ fetchPolicy: 'cache-only', | ||
id: id, | ||
__typename: fragmentTypeName, | ||
__typename: typename, | ||
}, | ||
@@ -35,0 +40,0 @@ }), data = _b.data, rest = __rest(_b, ["data"]); |
import * as React from 'react'; | ||
import { DocumentNode } from 'graphql'; | ||
export declare function useApolloFragment(fragment: string, id: string): { | ||
client: import("../../../../../../../Users/abhiaiyer/Projects/apollo-fragment/packages/apollo-fragment-react/node_modules/apollo-client/ApolloClient").default<any>; | ||
error?: import("../../../../../../../Users/abhiaiyer/Projects/apollo-fragment/packages/apollo-fragment-react/node_modules/apollo-client/errors/ApolloError").ApolloError | undefined; | ||
declare type FragmentQueryData<TData = any> = { | ||
getFragment?: TData; | ||
}; | ||
export declare function useApolloFragment<TData = any>(fragment: string, id: string): { | ||
client: import("../../../../../../../Users/abhiaiyer/gatsby/apollo-fragment/packages/apollo-fragment-react/node_modules/apollo-client/ApolloClient").default<any>; | ||
error?: import("../../../../../../../Users/abhiaiyer/gatsby/apollo-fragment/packages/apollo-fragment-react/node_modules/apollo-client/errors/ApolloError").ApolloError | undefined; | ||
loading: boolean; | ||
networkStatus: NetworkStatus; | ||
called: boolean; | ||
startPolling: (pollInterval: number) => void; | ||
stopPolling: () => void; | ||
subscribeToMore: <TSubscriptionData = any, TSubscriptionVariables = { | ||
id: string; | ||
__typename: any; | ||
}>(options: import("../../../../../../../Users/abhiaiyer/Projects/apollo-fragment/packages/apollo-fragment-react/node_modules/apollo-client/core/watchQueryOptions").SubscribeToMoreOptions<any, TSubscriptionVariables, TSubscriptionData>) => () => void; | ||
updateQuery: <TVars = { | ||
id: string; | ||
__typename: any; | ||
}>(mapFn: (previousQueryResult: any, options: import("../../../../../../../Users/abhiaiyer/Projects/apollo-fragment/packages/apollo-fragment-react/node_modules/apollo-client/core/ObservableQuery").UpdateQueryOptions<TVars>) => any) => void; | ||
refetch: (variables?: { | ||
id: string; | ||
__typename: any; | ||
} | undefined) => Promise<import("../../../../../../../Users/abhiaiyer/Projects/apollo-fragment/packages/apollo-fragment-react/node_modules/apollo-client/core/types").ApolloQueryResult<any>>; | ||
variables: { | ||
id: string; | ||
__typename: any; | ||
}; | ||
fetchMore: (<K extends "id" | "__typename">(fetchMoreOptions: import("../../../../../../../Users/abhiaiyer/Projects/apollo-fragment/packages/apollo-fragment-react/node_modules/apollo-client/core/watchQueryOptions").FetchMoreQueryOptions<{ | ||
id: string; | ||
__typename: any; | ||
}, K> & import("../../../../../../../Users/abhiaiyer/Projects/apollo-fragment/packages/apollo-fragment-react/node_modules/apollo-client/core/ObservableQuery").FetchMoreOptions<any, { | ||
id: string; | ||
__typename: any; | ||
}>) => Promise<import("../../../../../../../Users/abhiaiyer/Projects/apollo-fragment/packages/apollo-fragment-react/node_modules/apollo-client/core/types").ApolloQueryResult<any>>) & (<TData2, TVariables2, K extends keyof TVariables2>(fetchMoreOptions: { | ||
subscribeToMore: <TSubscriptionData = FragmentQueryData<TData>, TSubscriptionVariables = Record<string, any>>(options: import("../../../../../../../Users/abhiaiyer/gatsby/apollo-fragment/packages/apollo-fragment-react/node_modules/apollo-client/core/watchQueryOptions").SubscribeToMoreOptions<FragmentQueryData<TData>, TSubscriptionVariables, TSubscriptionData>) => () => void; | ||
updateQuery: <TVars = Record<string, any>>(mapFn: (previousQueryResult: FragmentQueryData<TData>, options: import("../../../../../../../Users/abhiaiyer/gatsby/apollo-fragment/packages/apollo-fragment-react/node_modules/apollo-client/core/ObservableQuery").UpdateQueryOptions<TVars>) => FragmentQueryData<TData>) => void; | ||
refetch: (variables?: Record<string, any> | undefined) => Promise<import("../../../../../../../Users/abhiaiyer/gatsby/apollo-fragment/packages/apollo-fragment-react/node_modules/apollo-client/core/types").ApolloQueryResult<FragmentQueryData<TData>>>; | ||
variables: Record<string, any>; | ||
fetchMore: (<K extends string>(fetchMoreOptions: import("../../../../../../../Users/abhiaiyer/gatsby/apollo-fragment/packages/apollo-fragment-react/node_modules/apollo-client/core/watchQueryOptions").FetchMoreQueryOptions<Record<string, any>, K> & import("../../../../../../../Users/abhiaiyer/gatsby/apollo-fragment/packages/apollo-fragment-react/node_modules/apollo-client/core/ObservableQuery").FetchMoreOptions<FragmentQueryData<TData>, Record<string, any>>) => Promise<import("../../../../../../../Users/abhiaiyer/gatsby/apollo-fragment/packages/apollo-fragment-react/node_modules/apollo-client/core/types").ApolloQueryResult<FragmentQueryData<TData>>>) & (<TData2, TVariables2, K extends keyof TVariables2>(fetchMoreOptions: { | ||
query?: DocumentNode | undefined; | ||
} & import("../../../../../../../Users/abhiaiyer/Projects/apollo-fragment/packages/apollo-fragment-react/node_modules/apollo-client/core/watchQueryOptions").FetchMoreQueryOptions<TVariables2, K> & import("../../../../../../../Users/abhiaiyer/Projects/apollo-fragment/packages/apollo-fragment-react/node_modules/apollo-client/core/ObservableQuery").FetchMoreOptions<TData2, TVariables2>) => Promise<import("../../../../../../../Users/abhiaiyer/Projects/apollo-fragment/packages/apollo-fragment-react/node_modules/apollo-client/core/types").ApolloQueryResult<TData2>>); | ||
data: any; | ||
} & import("../../../../../../../Users/abhiaiyer/gatsby/apollo-fragment/packages/apollo-fragment-react/node_modules/apollo-client/core/watchQueryOptions").FetchMoreQueryOptions<TVariables2, K> & import("../../../../../../../Users/abhiaiyer/gatsby/apollo-fragment/packages/apollo-fragment-react/node_modules/apollo-client/core/ObservableQuery").FetchMoreOptions<TData2, TVariables2>) => Promise<import("../../../../../../../Users/abhiaiyer/gatsby/apollo-fragment/packages/apollo-fragment-react/node_modules/apollo-client/core/types").ApolloQueryResult<TData2>>); | ||
data: TData | undefined; | ||
}; | ||
export declare function withApolloFragment(fragment: string, idPropName?: string): (WrappedComponent: React.ComponentType<any>) => React.ComponentClass<any, any>; | ||
export declare function ApolloFragment({ children, fragment, id }: any): JSX.Element; | ||
export {}; |
@@ -22,4 +22,9 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
export function useApolloFragment(fragment, id) { | ||
var _a = getFragmentInfo(fragment), fragmentTypeName = _a.fragmentTypeName, fragmentName = _a.fragmentName; | ||
var query = buildFragmentQuery({ fragment: fragment, fragmentName: fragmentName }); | ||
var _a = React.useMemo(function () { | ||
var _a = getFragmentInfo(fragment), fragmentTypeName = _a.fragmentTypeName, fragmentName = _a.fragmentName; | ||
return { | ||
query: buildFragmentQuery({ fragment: fragment, fragmentName: fragmentName }), | ||
typename: fragmentTypeName, | ||
}; | ||
}, [fragment]), query = _a.query, typename = _a.typename; | ||
var _b = useQuery(query, { | ||
@@ -29,3 +34,3 @@ fetchPolicy: 'cache-only', | ||
id: id, | ||
__typename: fragmentTypeName, | ||
__typename: typename, | ||
}, | ||
@@ -32,0 +37,0 @@ }), data = _b.data, rest = __rest(_b, ["data"]); |
{ | ||
"name": "apollo-fragment-react", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": | ||
@@ -5,0 +5,0 @@ "A Query component to connect React components to GraphQL fragments", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19327
201