mirror of
https://github.com/vale981/Vulcan
synced 2025-03-05 17:41:43 -05:00
Merge pull request #1851 from MHerszak/withEdit-withRemove
Added getCollection to withEdit & withRemove
This commit is contained in:
commit
8e507552df
2 changed files with 8 additions and 5 deletions
|
@ -25,18 +25,19 @@ Child Props:
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { graphql } from 'react-apollo';
|
import { graphql } from 'react-apollo';
|
||||||
import gql from 'graphql-tag';
|
import gql from 'graphql-tag';
|
||||||
import { getFragment, getFragmentName } from 'meteor/vulcan:core';
|
import { getFragment, getFragmentName, getCollection } from 'meteor/vulcan:core';
|
||||||
|
|
||||||
export default function withEdit(options) {
|
export default function withEdit(options) {
|
||||||
|
|
||||||
const {collection } = options,
|
const { collectionName } = options;
|
||||||
|
// get options
|
||||||
|
const collection = options.collection || getCollection(collectionName),
|
||||||
fragment = options.fragment || getFragment(options.fragmentName),
|
fragment = options.fragment || getFragment(options.fragmentName),
|
||||||
fragmentName = getFragmentName(fragment),
|
fragmentName = getFragmentName(fragment),
|
||||||
collectionName = collection.options.collectionName,
|
|
||||||
mutationName = collection.options.mutations.edit.name;
|
mutationName = collection.options.mutations.edit.name;
|
||||||
|
|
||||||
return graphql(gql`
|
return graphql(gql`
|
||||||
mutation ${mutationName}($documentId: String, $set: ${collectionName}Input, $unset: ${collectionName}Unset) {
|
mutation ${mutationName}($documentId: String, $set: ${collection.options.collectionName}Input, $unset: ${collection.options.collectionName}Unset) {
|
||||||
${mutationName}(documentId: $documentId, set: $set, unset: $unset) {
|
${mutationName}(documentId: $documentId, set: $set, unset: $unset) {
|
||||||
...${fragmentName}
|
...${fragmentName}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,12 @@ Child Props:
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { graphql } from 'react-apollo';
|
import { graphql } from 'react-apollo';
|
||||||
import gql from 'graphql-tag';
|
import gql from 'graphql-tag';
|
||||||
|
import { getCollection } from 'meteor/vulcan:core';
|
||||||
|
|
||||||
export default function withRemove(options) {
|
export default function withRemove(options) {
|
||||||
|
|
||||||
const { collection } = options,
|
const { collectionName } = options;
|
||||||
|
const collection = options.collection || getCollection(collectionName),
|
||||||
mutationName = collection.options.mutations.remove.name
|
mutationName = collection.options.mutations.remove.name
|
||||||
|
|
||||||
return graphql(gql`
|
return graphql(gql`
|
||||||
|
|
Loading…
Add table
Reference in a new issue