Grapher - Collection Relationship Manager + GraphQL Like Data Fetcher


#163

Updated to 1.2.7_2

  • Some bug fixes & security improvements

@klabauter nice!


#164

Hello,

Sorry for not contributing so much in the past months. Priorities shifted, redis-oplog had to be completed and brought to a prod-ready state, we had to deal with so many other projects.

Please read this ticket:

Thank you all for the support! If someone doesn’t have the time and wants to contribute can message me.


#165

Anybody here using Grapher together with React and could provide me with some code samples?
I am really having troubles to figure out a proper way to use React Component props in $filters of createQuery() and all that.
Am I correct that Grapher can indeed properly used for queries needed to be reactive? I need reactive queries but would love to use Grapher to “populate” my queries.


#166

Did you check-out the boilerplate ? It’s written with React. And yes, you can use it fro reactive-queries, we have created an additional grapher-react package that offeers seemless integration.


#167

I did have a look into your grapher-react package, but I didn’t know there was a boilerplate. Thank you for your quick reply, I’ll check out the boilerplate and go from there.


#168

This is a very interesting framework! it will solve ton of problems, but I have some questions:

1- regarding the numbers you mentioned about performance, is there any benchmarking that shows this?

2- I just scratched the surface reading a bit of the docs and reading in this thread, but, for Meteor+blaze mindset, I can’t see any Method declarations! and I think you already abstracted sub/pub using the querying mechanism, did you also abstracted Meteor Methods mechanism?
my question is, is there any documented mapping those concepts out, Meteor original concepts => grapher implementation? it would be helpful to briefly explain what happens behind the scene.
3- you talked about tutorials, is there any tutorials for Grapher + Blaze?

Thanks


#169

Sorry for delay.

  1. Nope, but 40x was for a 5 level graph, for 10 level it’s exponentially more. You can disable hypernova, I just did these benchmarks in the beginning.
  2. You can use grapher in your methods if it’s more familiar. Did you look at the guide fully ? It’s frontend agnostic.
  3. Not yet, sorry, other priorities arose :frowning:

#170

Thanks, Hope Grapher will gain more attraction, I can see it is very innovative


#171

Thank you @ahmad . Our company is using it in every project, and it’s just great, it solves the linking issue between collections and easily fetch them.


#172

Has any example with Vue JS?


#173

@theara , if you know how to use a call with a callback:

query = createQuery({ users: {} });
query.fetch((err, res) => { ... })

And inside that callback you do something vue related, it just works.

You can also use:
await query.fetchSync()

^ inside an async function, ofcourse

And if you want it reactive, this should do it: https://github.com/Akryum/vue-meteor

Grapher is UI Agnostic. It only has some tools for React, but feel free to build your own tools with it!

A very important thing to mention here is that grapher is also language agnostic:

  • You can in Meteor create a server-side route, that accepts a json object and return a json object.
  • You can do these kind of requests in any language:
// php sample

$body = [
     "users" => [
             "profile" => 1,               
     ]
]

$client->post('http://mybox/grapher',  ['body' => $body])

Use any authorization layer you wish. API Keys.


#174

Updated to 1.2.8

We have made some very small fixes for some issues, but the biggest achievement is full support for simpl-schema projects. Works with both versions out of the box, you don’t need to worry about it :slight_smile:

Internally we still use simple-schema package (old version) for validating configurations, but that won’t affect your code-base.

Grapher is continuing to be a very reliable tool for many projects. Thanks for the support so far, we’ll keep this thread updated.

Cheers!


#175

@ahmad @theara
If you know how to use Blaze/Vue with Collection.find().fetch(), you know how to use Grapher :stuck_out_tongue: The only thing with Blaze is that Templates won’t automatically unsubscribe to queries, so you have to do it yourself in Template.onDestroyed().

In regards to Vue, Grapher uses Meteor’s reactivity, so if you call query.fetch() inside a vue-meteor-tracker helper (just like you need to do with regular Collection.find().fetch()), you will get reactivity.

I wrote a Vue mixin to give me the same template subscription handling that Blaze has. I might make it a package if anyone is interested, or just paste the code, it’s not very long.


#176

I’d be interested in seeing that :slight_smile:


#177

Hi,

First of all good jod @diaconutheodor !!

I need help! I have a problem with with check() and grapher, the console returns the Exception when I try to render data with react:

Exception from sub exposure_Profiles id JNZf2XCGwZ5dP3nmr Error: Did not check() all arguments during publisher 'exposure_Profiles'
I20170715-01:24:26.952(2)?     at [object Object]._.extend.throwUnlessAllArgumentsHaveBeenChecked (packages/check.js:484:13)
I20170715-01:24:26.952(2)?     at Object.exports.Match._failIfArgumentsAreNotAllChecked (packages/check.js:132:16)
I20170715-01:24:26.953(2)?     at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1734:18)
I20170715-01:24:26.953(2)?     at [object Object]._.extend._runHandler (packages/ddp-server/livedata_server.js:1035:17)
I20170715-01:24:26.953(2)?     at [object Object]._.extend._startSubscription (packages/ddp-server/livedata_server.js:853:9)
I20170715-01:24:26.954(2)?     at [object Object]._.extend.protocol_handlers.sub (packages/ddp-server/livedata_server.js:625:12)
I20170715-01:24:26.954(2)?     at packages/ddp-server/livedata_server.js:559:43

On the expose.js I have:

import Profiles from './Profiles';

Profiles.expose();

And my publish:

Meteor.publish('profiles.view', function profilesView(profileId) {
  check(profileId, String);
  return Profiles.find({ _id: profileId, owner: this.userId });
});

#178

Do you have this package: https://docs.meteor.com/packages/audit-argument-checks.html ?

If so, try removing it. Currently I do not use check to check the arguments in a method or exposure, but it makes sense to do it. I’ll add it as a issue in github


#179

Thanks for the reply @diaconutheodor, issue has been solved !!!

But now I have a problem with queries, I can´t get the data from the linked collection, the query only give me the main collection data.

This is the code of my view with react component (using grapher-react lib)

import React from 'react';
import Profiles from '../../../api/Profiles/Profiles';
import { createQueryContainer } from 'meteor/cultofcoders:grapher-react';

const query = Profiles.createQuery({
    name: 1,
    description: 1,
    Groups: {
      name: 1,
      description: 1
    }
});

query.subscribe();

const ProfileList = ({loading, error, profiles}) => (
  <div>Items:
    {
      _.map(profiles, profile => <div>{JSON.stringify(profile)}</div>)
    }
  </div>
);

export default createQueryContainer(query, ProfileList, {
    reactive: true,
    dataProp: 'profiles',
    single: false
});

Groups doesn´t appear on the example print data “{JSON.stringify(profile)}”, only get name, description and id profile´s

The “relationship” is a many-to-many between Profiles and Groups.

import Profiles from './Profiles';
import Groups from '../Groups/Groups';

Profiles.addLinks({
    groups: {
      type: 'many',
      collection: Groups,
      field: 'groupIds'
    }
});

Groups.addLinks({
    profiles: {
        collection: Profiles,
        inversedBy: 'groups'
    }
});

And them I expose with

Profiles.expose();

What am I doing wrong?


#180

Groups should not be capitalized here :slight_smile:


#181

I just tried with with “groups” instead of “Groups” but with the same result. :sweat:


#182

you use .addLinks({groups}) then you query for Groups, capital G.