maxcoto / graphoid Goto Github PK
View Code? Open in Web Editor NEWInstant GraphQL REST-API for Rails from ActiveRecord or Mongoid models https://maxcoto.github.io/graphoid/
License: MIT License
Instant GraphQL REST-API for Rails from ActiveRecord or Mongoid models https://maxcoto.github.io/graphoid/
License: MIT License
Hello @maxiperezc
Firstly, congratulations for your Graphoid
gem, which automatically creates the basic GraphQL Queries and Mutations via ruby metaprogramming.
I wanna ask you a question regarding an issue, I believe a feature is not implemented on Graphoid
yet...
How can I perform Multiple Queries on Graphoid?References: https://hasura.io/docs/1.0/graphql/manual/queries/multiple-queries.html
On GraphQL, it is possible to perform Multiple Queries. However, somehow, the Graphoid
gem is restricting this feature.
In fact, an error is being shown when trying to perform multiple queries
Please, take look at the below picture..
With single queries, it works wonderfully, but I need to do multiple queries in my project :/
If it is not yet implemented on the Graphoid
gem, can you give me an idea where I need to touch to enable this feature?
I'm willing to play with with Graphoid's
internal code in order to make Multiple Queries this possible.
Best regards;
Thank You very much!
--
Hi! Love this gem, thanks for creating it!
I've had issues implementing it in a project and isolated it to the fact that we used ruby-graphql >=1.9. Upgrading the root .gemspec
and the tester_ar
project to 1.9 allowed me to reproduce this.
The relationships are not being added to the queries as they were before. However, relocating the include Graphoid::Queries
to the bottom of the model classes (or just below all relationship definitions) will add some of these, depending on the order they're being mapped over by Graphoid::Types
. For instance, the User
model goes first, and the Graphoid::Queries::LIST
is empty, while Account
goes last and is able to add User
relations due to it being present in LIST
by that point.
I've been looking through the ruby-graphql changelog for 1.9.0 and can't really identify some obvious reason for this to break. I checked ruby-graphql 1.8.17 which works as expected.
I'll continue investigating this...
Hey @maxiperezc!
Thanks for the great gem! I'm really curious to give it a try in my app. :)
I'm trying to figure out where I'd add authorization, so that I can, for example, restrict access to non-published Posts, or prevent user/guest from creating new Blogs, etc.
I've found Permissions section in the docs, but (as far as I understand) it's actually only for hiding certain fields from the API.
Thanks!
Hi. First of all thanks for this gem. I'm trying to incorporate it into an existing rails 5.2 application but run into some weird/fun loading issues. In various initializers I have pieces of code that is required for my application to boot. For example I define a class that the application code uses etc. When I install graphoid by adding the gem to the bundle and creating the initializer as per the instructions, I would get errors for example for this missing class. If I rename config/initializers/graphoid.rb
to config/initializers/zz_graphoid.rb
(so it is the last initializer to run), booting the app works as expected.
From looking at the sourcecode of the gem I suspect it's because it asks rails to eager_load. I could be wrong :)
Is there an alternative approach? Relying on the load order seems a little brittle... :)
Right now has_many
association still have N+1 issue:
Entity Load (1.0ms) SELECT "entities".* FROM "entities" WHERE "entities"."deleted_at" IS NULL
↳ app/controllers/graphql_controller.rb:10
Location Load (5.9ms) SELECT "locations".* FROM "locations" WHERE "locations"."deleted_at" IS NULL AND "locations"."entity_uuid" = $1 [["entity_uuid", "b0d49d56-16d2-4d9f-a946-db7504271799"]]
↳ app/controllers/graphql_controller.rb:10
Location Load (0.3ms) SELECT "locations".* FROM "locations" WHERE "locations"."deleted_at" IS NULL AND "locations"."entity_uuid" = $1 [["entity_uuid", "1a9bfbec-b2e6-4eb8-a64b-17a3ae77cf2a"]]
↳ app/controllers/graphql_controller.rb:10
Location Load (0.3ms) SELECT "locations".* FROM "locations" WHERE "locations"."deleted_at" IS NULL AND "locations"."entity_uuid" = $1 [["entity_uuid", "c88f263b-eea1-43cb-9a8d-acf55014a875"]]
↳ app/controllers/graphql_controller.rb:10
Location Load (0.3ms) SELECT "locations".* FROM "locations" WHERE "locations"."deleted_at" IS NULL AND "locations"."entity_uuid" = $1 [["entity_uuid", "8adb8c4a-bc72-4d9d-932d-5e2a34a65fdb"]]
↳ app/controllers/graphql_controller.rb:10
Location Load (0.4ms) SELECT "locations".* FROM "locations" WHERE "locations"."deleted_at" IS NULL AND "locations"."entity_uuid" = $1 [["entity_uuid", "c3892ae1-f9e3-487c-9224-4a28b097b575"]]
↳ app/controllers/graphql_controller.rb:10
Location Load (0.3ms) SELECT "locations".* FROM "locations" WHERE "locations"."deleted_at" IS NULL AND "locations"."entity_uuid" = $1 [["entity_uuid", "0d350ec8-9b81-4194-8623-3f5079173c89"]]
↳ app/controllers/graphql_controller.rb:10
Location Load (0.2ms) SELECT "locations".* FROM "locations" WHERE "locations"."deleted_at" IS NULL AND "locations"."entity_uuid" = $1 [["entity_uuid", "78a38941-a0c1-4066-b740-d9382bf6b78f"]]
↳ app/controllers/graphql_controller.rb:10
You may want to take a look at this link: https://graphql-ruby.org/schema/lazy_execution
Fetching [email protected]:maxiperezc/graphoid.git
Resolving dependencies...
Bundler could not find compatible versions for gem "rails":
In snapshot (Gemfile.lock):
rails (= 5.2.2)
In Gemfile:
rails (~> 5.2.2)
graphoid was resolved to 0.0.5, which depends on
rails (~> 5.1.6)
Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.