Upgraded to 1.0.6

This commit is contained in:
Theodor Diaconu 2016-09-19 12:22:20 +03:00
parent 7450b70e1a
commit 15dcf8b98e
6 changed files with 30 additions and 6 deletions

View file

@ -1,3 +1,7 @@
## 1.0.6
- Fixed exposure bug for static fetching
- Exporting useful components that allow you to customly build your data graph
## 1.0.4 ## 1.0.4
- Index for meta will now only index _id - Index for meta will now only index _id
- You can now perform actions from the inversed links - You can now perform actions from the inversed links

View file

@ -148,6 +148,9 @@ query.setParams({limit: 200});
``` ```
// server side // server side
const data = query.fetch(); const data = query.fetch();
const data = query.fetch({
userId: 'Id of the user you want to impersonate, for exposure, null can be used'
})
// client side // client side
query.fetch((error, response) => {...}); query.fetch((error, response) => {...});

View file

@ -19,7 +19,7 @@ export default function fetch(node, parentObject, userId) {
results = accessor.fetch(filters, options, userId); results = accessor.fetch(filters, options, userId);
} else { } else {
if (node.collection.findSecure) { if (node.collection.findSecure) {
results = node.collection.find(filters, options, userId).fetch(); results = node.collection.findSecure(filters, options, userId).fetch();
} else { } else {
results = node.collection.find(filters, options).fetch(); results = node.collection.find(filters, options).fetch();
} }

View file

@ -56,7 +56,7 @@ export default class Query {
throw new Meteor.Error('not-allowed', 'You are on client so you must either provide a callback to get the data or subscribe first.'); throw new Meteor.Error('not-allowed', 'You are on client so you must either provide a callback to get the data or subscribe first.');
} }
if (Meteor.isServer && callback) { if (Meteor.isServer && callback && _.isFunction(callback)) {
throw new Meteor.Error('not-allowed', 'You are on server, fetching is done directly so no need for callback.'); throw new Meteor.Error('not-allowed', 'You are on server, fetching is done directly so no need for callback.');
} }
@ -74,12 +74,13 @@ export default class Query {
} }
} else { } else {
// fetch directly, he is from server // fetch directly, he is from server
const options = _.isObject(callback) ? callback : {};
const node = createGraph( const node = createGraph(
this.collection, this.collection,
applyFilterFunction(this.body, this.params) applyFilterFunction(this.body, this.params)
); );
return recursiveFetch(node); return recursiveFetch(node, null, options.userId);
} }
} }

View file

@ -3,4 +3,20 @@ import './lib/query/extension.js';
export { export {
default as createQuery default as createQuery
} from './lib/query/createQuery.js'; } from './lib/query/createQuery.js';
export {
default as createGraph
} from './lib/query/lib/createGraph.js';
export {
default as recursiveFetch
} from './lib/query/lib/recursiveFetch.js';
export {
default as recursiveCompose
} from './lib/query/lib/recursiveCompose.js';
export {
default as applyFilterFunction
} from './lib/query/lib/applyFilterFunction.js';

View file

@ -1,6 +1,6 @@
Package.describe({ Package.describe({
name: 'cultofcoders:grapher', name: 'cultofcoders:grapher',
version: '1.0.4', version: '1.0.6',
// Brief, one-line summary of the package. // Brief, one-line summary of the package.
summary: 'Grapher is a way of linking/joining collections. And fetching data in a GraphQL style.', summary: 'Grapher is a way of linking/joining collections. And fetching data in a GraphQL style.',
// URL to the Git repository containing the source code for this package. // URL to the Git repository containing the source code for this package.
@ -27,9 +27,9 @@ Package.onUse(function (api) {
api.use(packages); api.use(packages);
api.imply(packages); api.imply(packages);
api.mainModule('main.both.js');
api.mainModule('main.client.js', 'client'); api.mainModule('main.client.js', 'client');
api.mainModule('main.server.js', 'server'); api.mainModule('main.server.js', 'server');
api.mainModule('main.both.js');
}); });
Package.onTest(function (api) { Package.onTest(function (api) {