apollo-fragment-react
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -24,12 +24,12 @@ (function (global, factory) { | ||
}; | ||
function withApolloFragment(fragment) { | ||
function withApolloFragment(fragment, idPropName) { | ||
if (idPropName === void 0) { idPropName = 'id'; } | ||
var _a = apolloFragmentUtils.getFragmentInfo(fragment), fragmentTypeName = _a.fragmentTypeName, fragmentName = _a.fragmentName; | ||
var query = apolloFragmentUtils.buildFragmentQuery({ fragment: fragment, fragmentName: fragmentName }); | ||
return reactApollo.graphql(query, { | ||
options: function (_a) { | ||
var id = _a.id; | ||
options: function (props) { | ||
return { | ||
fetchPolicy: 'cache-only', | ||
variables: { | ||
id: id, | ||
id: props[idPropName], | ||
__typename: fragmentTypeName, | ||
@@ -36,0 +36,0 @@ }, |
import * as React from 'react'; | ||
export declare function withApolloFragment(fragment: string): (WrappedComponent: React.ComponentType<any>) => React.ComponentClass<any>; | ||
export declare function withApolloFragment(fragment: string, idPropName?: string): (WrappedComponent: React.ComponentType<any>) => React.ComponentClass<any>; | ||
export declare function ApolloFragment({ children, fragment, id }: any): JSX.Element; |
@@ -21,12 +21,12 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
import { getFragmentInfo, buildFragmentQuery } from 'apollo-fragment-utils'; | ||
export function withApolloFragment(fragment) { | ||
export function withApolloFragment(fragment, idPropName) { | ||
if (idPropName === void 0) { idPropName = 'id'; } | ||
var _a = getFragmentInfo(fragment), fragmentTypeName = _a.fragmentTypeName, fragmentName = _a.fragmentName; | ||
var query = buildFragmentQuery({ fragment: fragment, fragmentName: fragmentName }); | ||
return graphql(query, { | ||
options: function (_a) { | ||
var id = _a.id; | ||
options: function (props) { | ||
return { | ||
fetchPolicy: 'cache-only', | ||
variables: { | ||
id: id, | ||
id: props[idPropName], | ||
__typename: fragmentTypeName, | ||
@@ -33,0 +33,0 @@ }, |
{ | ||
"name": "apollo-fragment-react", | ||
"version": "0.5.0", | ||
"version": "0.5.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
198211
8