mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -05:00
Add new removeFromFragment function; fix collection.removeField
This commit is contained in:
parent
5f7863c85e
commit
2981ca3e93
4 changed files with 12 additions and 4 deletions
|
@ -11,7 +11,7 @@ export {
|
|||
// collections
|
||||
Collections, createCollection,
|
||||
// fragments
|
||||
Fragments, registerFragment, getFragment, getFragmentName, extendFragment,
|
||||
Fragments, registerFragment, getFragment, getFragmentName, extendFragment, removeFromFragment,
|
||||
// graphql
|
||||
GraphQLSchema, addGraphQLSchema, addGraphQLQuery, addGraphQLMutation, addGraphQLResolvers, removeGraphQLResolver, addToGraphQLContext,
|
||||
// headtags
|
||||
|
|
|
@ -14,7 +14,8 @@ SimpleSchema.extendOptions([
|
|||
]);
|
||||
|
||||
/**
|
||||
* @summary replacement for Collection2's attachSchema
|
||||
* @summary replacement for Collection2's attachSchema. Pass either a schema, to
|
||||
* initialize or replace the schema, or some fields, to extend the current schema
|
||||
* @class Mongo.Collection
|
||||
*/
|
||||
Mongo.Collection.prototype.attachSchema = function (schemaOrFields) {
|
||||
|
@ -57,7 +58,7 @@ Mongo.Collection.prototype.removeField = function (fieldName) {
|
|||
var schema = _.omit(collection.simpleSchema()._schema, fieldName);
|
||||
|
||||
// add field schema to collection schema
|
||||
collection.attachSchema(schema, {replace: true});
|
||||
collection.attachSchema(new SimpleSchema(schema));
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,6 +28,13 @@ export const extendFragment = (fragmentName, newProperties) => {
|
|||
registerFragment(newFragmentText);
|
||||
}
|
||||
|
||||
// remove a property from a fragment
|
||||
export const removeFromFragment = (fragmentName, propertyName) => {
|
||||
const fragment = Fragments[fragmentName];
|
||||
const newFragmentText = fragment.fragmentText.replace(propertyName, '');
|
||||
registerFragment(newFragmentText);
|
||||
}
|
||||
|
||||
// get fragment name from fragment object
|
||||
export const getFragmentName = fragment => fragment && fragment.definitions[0] && fragment.definitions[0].name.value;
|
||||
|
||||
|
|
|
@ -19,5 +19,5 @@ export { getSetting } from './settings.js';
|
|||
export { Strings, addStrings } from './strings.js';
|
||||
export { configureStore, getActions, addAction, getReducers, addReducer, getMiddlewares, addMiddleware } from './redux.js';
|
||||
export { Headtags } from './headtags.js';
|
||||
export { Fragments, registerFragment, getFragment, getFragmentName, extendFragment } from './fragments.js';
|
||||
export { Fragments, registerFragment, getFragment, getFragmentName, extendFragment, removeFromFragment } from './fragments.js';
|
||||
export { createApolloClient } from './apollo.js';
|
Loading…
Add table
Reference in a new issue