apollo-fragment-react
Advanced tools
Comparing version 0.3.0 to 0.4.0
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('graphql-tag'), require('react-apollo')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'react', 'graphql-tag', 'react-apollo'], factory) : | ||
(factory((global.apolloFragmentReact = global.apolloFragmentReact || {}, global.apolloFragmentReact.state = {}),global.React,global.gql,global.reactApollo)); | ||
}(this, (function (exports,React,gql,reactApollo) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-apollo'), require('apollo-fragment-utils')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-apollo', 'apollo-fragment-utils'], factory) : | ||
(factory((global.apolloFragmentReact = global.apolloFragmentReact || {}, global.apolloFragmentReact.state = {}),global.React,global.reactApollo,global.apolloFragmentUtils)); | ||
}(this, (function (exports,React,reactApollo,apolloFragmentUtils) { 'use strict'; | ||
gql = gql && gql.hasOwnProperty('default') ? gql['default'] : gql; | ||
var __assign = (undefined && undefined.__assign) || Object.assign || function(t) { | ||
@@ -26,20 +24,5 @@ for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
}; | ||
function getFragmentInfo(fragment) { | ||
var fragmentAST = gql(fragment); | ||
var fragmentDefinitions = fragmentAST.definitions && fragmentAST.definitions[0]; | ||
var fragmentName = fragmentDefinitions && fragmentDefinitions.name.value; | ||
var fragmentTypeName = fragmentDefinitions && fragmentDefinitions.typeCondition.name.value; | ||
return { | ||
fragmentName: fragmentName, | ||
fragmentTypeName: fragmentTypeName, | ||
}; | ||
} | ||
function buildFragmentQuery(_a) { | ||
var fragment = _a.fragment, fragmentName = _a.fragmentName; | ||
return (_b = ["\n query getFragment($id: ID, $__typename: String) {\n getFragment(id: $id, __typename: $__typename) @client {\n ...", "\n }\n }\n ", "\n "], _b.raw = ["\n query getFragment($id: ID, $__typename: String) {\n getFragment(id: $id, __typename: $__typename) @client {\n ...", "\n }\n }\n ", "\n "], gql(_b, fragmentName, fragment)); | ||
var _b; | ||
} | ||
function withApolloFragment(fragment) { | ||
var _a = getFragmentInfo(fragment), fragmentTypeName = _a.fragmentTypeName, fragmentName = _a.fragmentName; | ||
var query = buildFragmentQuery({ fragment: fragment, fragmentName: fragmentName }); | ||
var _a = apolloFragmentUtils.getFragmentInfo(fragment), fragmentTypeName = _a.fragmentTypeName, fragmentName = _a.fragmentName; | ||
var query = apolloFragmentUtils.buildFragmentQuery({ fragment: fragment, fragmentName: fragmentName }); | ||
return reactApollo.graphql(query, { | ||
@@ -63,4 +46,4 @@ options: function (_a) { | ||
var children = _a.children, fragment = _a.fragment, id = _a.id; | ||
var _b = getFragmentInfo(fragment), fragmentTypeName = _b.fragmentTypeName, fragmentName = _b.fragmentName; | ||
var query = buildFragmentQuery({ fragment: fragment, fragmentName: fragmentName }); | ||
var _b = apolloFragmentUtils.getFragmentInfo(fragment), fragmentTypeName = _b.fragmentTypeName, fragmentName = _b.fragmentName; | ||
var query = apolloFragmentUtils.buildFragmentQuery({ fragment: fragment, fragmentName: fragmentName }); | ||
return (React.createElement(reactApollo.Query, { query: query, variables: { id: id, __typename: fragmentTypeName } }, function (_a) { | ||
@@ -67,0 +50,0 @@ var data = _a.data, rest = __rest(_a, ["data"]); |
@@ -1,8 +0,3 @@ | ||
/// <reference types="react" /> | ||
import * as React from 'react'; | ||
export declare type buildFragmentQueryType = { | ||
fragment: string; | ||
fragmentName: string; | ||
}; | ||
export declare function withApolloFragment(fragment: string): (WrappedComponent: React.ComponentType<any>) => React.ComponentClass<any>; | ||
export declare function ApolloFragment({children, fragment, id}: any): JSX.Element; | ||
export declare function ApolloFragment({ children, fragment, id }: any): JSX.Element; |
@@ -19,19 +19,4 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
import * as React from 'react'; | ||
import gql from 'graphql-tag'; | ||
import { Query, graphql } from 'react-apollo'; | ||
function getFragmentInfo(fragment) { | ||
var fragmentAST = gql(fragment); | ||
var fragmentDefinitions = fragmentAST.definitions && fragmentAST.definitions[0]; | ||
var fragmentName = fragmentDefinitions && fragmentDefinitions.name.value; | ||
var fragmentTypeName = fragmentDefinitions && fragmentDefinitions.typeCondition.name.value; | ||
return { | ||
fragmentName: fragmentName, | ||
fragmentTypeName: fragmentTypeName, | ||
}; | ||
} | ||
function buildFragmentQuery(_a) { | ||
var fragment = _a.fragment, fragmentName = _a.fragmentName; | ||
return (_b = ["\n query getFragment($id: ID, $__typename: String) {\n getFragment(id: $id, __typename: $__typename) @client {\n ...", "\n }\n }\n ", "\n "], _b.raw = ["\n query getFragment($id: ID, $__typename: String) {\n getFragment(id: $id, __typename: $__typename) @client {\n ...", "\n }\n }\n ", "\n "], gql(_b, fragmentName, fragment)); | ||
var _b; | ||
} | ||
import { getFragmentInfo, buildFragmentQuery } from 'apollo-fragment-utils'; | ||
export function withApolloFragment(fragment) { | ||
@@ -38,0 +23,0 @@ var _a = getFragmentInfo(fragment), fragmentTypeName = _a.fragmentTypeName, fragmentName = _a.fragmentName; |
{ | ||
"name": "apollo-fragment-react", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": | ||
@@ -50,3 +50,3 @@ "A Query component to connect React components to GraphQL fragments", | ||
"apollo-link-state": "0.4.1", | ||
"react-apollo": "2.1.4" | ||
"react-apollo": "2.1.9" | ||
}, | ||
@@ -72,2 +72,3 @@ "devDependencies": { | ||
"react": "^16.3.2", | ||
"react-apollo": "^2.1.9", | ||
"rimraf": "2.6.1", | ||
@@ -79,3 +80,3 @@ "rollup": "0.56.x", | ||
"tslint": "5.8.0", | ||
"typescript": "2.5.1", | ||
"typescript": "^2.9.2", | ||
"uglify-js": "3.1.5" | ||
@@ -93,2 +94,3 @@ }, | ||
"dependencies": { | ||
"apollo-fragment-utils": "^0.1.0", | ||
"apollo-utilities": "^1.0.12" | ||
@@ -95,0 +97,0 @@ }, |
Sorry, the diff of this file is not supported yet
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
197620
4
27
136
+ Addedapollo-fragment-utils@^0.1.0
+ Addedapollo-fragment-utils@0.1.3(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedreact-apollo@2.1.9(transitive)
- Removedlodash@4.17.5(transitive)
- Removedreact-apollo@2.1.4(transitive)