mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
get fragmentName from fragment, no need to define it separately anymore
This commit is contained in:
parent
1c421f7c9e
commit
09cce8f978
15 changed files with 10 additions and 23 deletions
|
@ -68,7 +68,6 @@ CustomPostsItem.propTypes = {
|
|||
post: React.PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
CustomPostsItem.fragmentName = 'PostsItemFragment';
|
||||
CustomPostsItem.fragment = gql`
|
||||
fragment PostsItemFragment on Post {
|
||||
_id
|
||||
|
|
|
@ -27,7 +27,6 @@ const MoviesDetails = props => {
|
|||
}
|
||||
}
|
||||
|
||||
MoviesDetails.fragmentName = 'moviesDetailsFragment';
|
||||
MoviesDetails.fragment = gql`
|
||||
fragment moviesDetailsFragment on Movie {
|
||||
_id
|
||||
|
@ -45,7 +44,6 @@ MoviesDetails.fragment = gql`
|
|||
const options = {
|
||||
collection: Movies,
|
||||
queryName: 'moviesSingleQuery',
|
||||
fragmentName: MoviesDetails.fragmentName,
|
||||
fragment: MoviesDetails.fragment,
|
||||
};
|
||||
|
||||
|
|
|
@ -68,7 +68,6 @@ class MoviesItem extends Component {
|
|||
|
||||
};
|
||||
|
||||
MoviesItem.fragmentName = 'moviesItemFragment';
|
||||
MoviesItem.fragment = gql`
|
||||
fragment moviesItemFragment on Movie {
|
||||
_id
|
||||
|
|
|
@ -61,7 +61,6 @@ class MoviesList extends Component {
|
|||
const listOptions = {
|
||||
collection: Movies,
|
||||
queryName: 'moviesListQuery',
|
||||
fragmentName: MoviesItem.fragmentName,
|
||||
fragment: MoviesItem.fragment,
|
||||
};
|
||||
|
||||
|
|
|
@ -176,7 +176,6 @@ const fragment = gql`
|
|||
const categoriesListOptions = {
|
||||
collection: Categories,
|
||||
queryName: 'getCategoriesList',
|
||||
fragmentName: 'categoriesListFragment',
|
||||
fragment: fragment
|
||||
};
|
||||
|
||||
|
|
|
@ -50,7 +50,6 @@ PostsCommentsThread.propTypes = {
|
|||
currentUser: React.PropTypes.object
|
||||
};
|
||||
|
||||
PostsCommentsThread.fragmentName = 'commentsListFragment';
|
||||
PostsCommentsThread.fragment = gql`
|
||||
fragment commentsListFragment on Comment {
|
||||
_id
|
||||
|
@ -72,7 +71,6 @@ PostsCommentsThread.fragment = gql`
|
|||
const options = {
|
||||
collection: Comments,
|
||||
queryName: 'commentsListQuery',
|
||||
fragmentName: PostsCommentsThread.fragmentName,
|
||||
fragment: PostsCommentsThread.fragment,
|
||||
};
|
||||
|
||||
|
|
|
@ -81,7 +81,6 @@ PostsItem.propTypes = {
|
|||
post: React.PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
PostsItem.fragmentName = 'PostsItemFragment';
|
||||
PostsItem.fragment = gql`
|
||||
fragment PostsItemFragment on Post {
|
||||
_id
|
||||
|
|
|
@ -61,7 +61,6 @@ PostsList.propTypes = {
|
|||
// listResolverName: 'postsList',
|
||||
// totalResolverName: 'postsListTotal',
|
||||
// fragment: Posts.fragments.list,
|
||||
// fragmentName: 'fullPostInfo',
|
||||
// ownPropsVariables: [
|
||||
// // test note: can't overwrite atm
|
||||
// // {propName: 'limit', graphqlType: 'Int', defaultValue: 2, usedForTotal: false},
|
||||
|
@ -74,7 +73,6 @@ PostsList.propTypes = {
|
|||
const options = {
|
||||
collection: Posts,
|
||||
queryName: 'postsListQuery',
|
||||
fragmentName: Telescope.getRawComponent('PostsItem').fragmentName,
|
||||
fragment: Telescope.getRawComponent('PostsItem').fragment,
|
||||
};
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ PostsPage.propTypes = {
|
|||
document: React.PropTypes.object
|
||||
}
|
||||
|
||||
PostsPage.fragmentName = 'PostsSingleFragment'
|
||||
PostsPage.fragment = gql`
|
||||
fragment PostsSingleFragment on Post {
|
||||
_id
|
||||
|
@ -91,7 +90,6 @@ PostsPage.fragment = gql`
|
|||
const options = {
|
||||
collection: Posts,
|
||||
queryName: 'postsSingleQuery',
|
||||
fragmentName: PostsPage.fragmentName,
|
||||
fragment: PostsPage.fragment,
|
||||
};
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ UsersProfile.propTypes = {
|
|||
|
||||
UsersProfile.displayName = "UsersProfile";
|
||||
|
||||
UsersProfile.fragmentName = 'usersSingleFragment';
|
||||
UsersProfile.fragment = gql`
|
||||
fragment usersSingleFragment on User {
|
||||
_id
|
||||
|
@ -92,7 +91,6 @@ UsersProfile.fragment = gql`
|
|||
const options = {
|
||||
collection: Users,
|
||||
queryName: 'usersSingleQuery',
|
||||
fragmentName: UsersProfile.fragmentName,
|
||||
fragment: UsersProfile.fragment,
|
||||
};
|
||||
|
||||
|
|
|
@ -28,7 +28,8 @@ import gql from 'graphql-tag';
|
|||
|
||||
export default function withEdit(options) {
|
||||
|
||||
const {collection, fragmentName, fragment } = options,
|
||||
const {collection, fragment } = options,
|
||||
fragmentName = fragment.definitions[0].name.value,
|
||||
collectionName = collection._name,
|
||||
mutationName = collection.options.mutations.edit.name;
|
||||
|
||||
|
|
|
@ -4,8 +4,9 @@ import { graphql } from 'react-apollo';
|
|||
import gql from 'graphql-tag';
|
||||
|
||||
export default function withList (options) {
|
||||
|
||||
const { queryName, collection, fragment, fragmentName } = options,
|
||||
console.log(options)
|
||||
const { queryName, collection, fragment } = options,
|
||||
fragmentName = fragment.definitions[0].name.value,
|
||||
listResolverName = collection.options.resolvers.list.name,
|
||||
totalResolverName = collection.options.resolvers.total.name;
|
||||
|
||||
|
|
|
@ -29,7 +29,8 @@ import update from 'immutability-helper';
|
|||
export default function withNew(options) {
|
||||
|
||||
// get options
|
||||
const { collection, fragmentName, fragment, queryToUpdate } = options,
|
||||
const { collection, fragment, queryToUpdate } = options,
|
||||
fragmentName = fragment.definitions[0].name.value,
|
||||
collectionName = collection._name,
|
||||
mutationName = collection.options.mutations.new.name,
|
||||
listResolverName = collection.options.resolvers.list.name,
|
||||
|
|
|
@ -4,8 +4,9 @@ import { graphql } from 'react-apollo';
|
|||
import gql from 'graphql-tag';
|
||||
|
||||
export default function withSingle (options) {
|
||||
|
||||
const { queryName, collection, fragment, fragmentName } = options,
|
||||
|
||||
const { queryName, collection, fragment } = options,
|
||||
fragmentName = fragment.definitions[0].name.value,
|
||||
singleResolverName = collection.options.resolvers.single.name;
|
||||
|
||||
return graphql(gql`
|
||||
|
|
|
@ -95,7 +95,6 @@ class FormWrapper extends Component{
|
|||
let WrappedComponent;
|
||||
|
||||
const prefix = `${this.props.collection._name}${Telescope.utils.capitalize(this.getFormType())}`
|
||||
const fragmentName = `${prefix}FormFragment`;
|
||||
|
||||
// props received from parent component (i.e. <NovaForm/> call)
|
||||
const parentProps = this.props;
|
||||
|
@ -109,7 +108,6 @@ class FormWrapper extends Component{
|
|||
// generic options for the withSingle, withNew, withEdit, and withRemove HoCs
|
||||
const options = {
|
||||
collection: this.props.collection,
|
||||
fragmentName: fragmentName,
|
||||
fragment: this.getFragment(),
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue