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