Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite metaprogramming to support graphql 2.0.21 (#20)
# Description ✍️ Rewrites graphoid metaprogramming schema generators to support the major upgrades from graphql `1.x.x` ➡️ `2.x.x`. The tests rails app was also updated with rails 7.0 and with support to ruby 3.2.2. ## Deprecations ####⚠️ include modules deprecations `include Graphoiq::Queries` and `include Graphoid::Mutations` are not supported anymore. Now we should setup all generators in a initializer file following this example: ```rb # config/initializers/graphoid.rb Rails.application.config.after_initialize do Graphoid.configure do |config| config.driver = :mongoid end Graphoid.initialize Graphoid::Types.initialize(User, House, Label, Snake, Value, Person, Account, Contract) Graphoid::Queries.generate(User, House, Label, Snake, Value, Person, Account, Contract) Graphoid::Mutations.generate(User, House, Label, Snake, Value, Person, Account, Contract) end ``` ####⚠️ Removed ActiveRecord support ####⚠️ Removed createMany, updateMany and deleteMany mutations ####⚠️ Removed filters inside belongs to and has_one nested fields ```gql { users(where: { project: { ... } }) { id project { id } } ``` ####⚠️ Removed sort of nested fields ```gql { users(sort: { projects: { id: DESC } }) { id project { id } } ``` ### Quick test ``` cd spec/tester_mongo/ bundle install -j 5 rails s # http://127.0.0.1:3000/graphiql ``` # roadmap - [x] single query project { } - [x] many query projects { } - [x] where query projects(where: { }) { } - [x] order query projects(order: { }) { } - [x] create mutation createProject { } - [x] update mutation updateProject { } - [x] delete mutation deleteProject { } - [x] query with nested fields single on result projects { example { text } } - [x] query with nested fields on result projects { examples { text } } - [x] overcoming circular dependency on types (used string types declaration) - [x] query with nested fields on where projects(where: { example: { text: "test" } }) { } - [x] query with nested fields on result and where projects { examples(where: ...) { text } } - [x] query with some, none and every operators projects { examples(where: { field_some: ...}) { text } } - [x] Improve initialization and module enabling on models - [x] enable graphields - [x] enable graphorbid - [x] tests - [x] require all files upfront - [ ] support Rails.appplication.eager_load! # Working without crashes but no native eager load ```gql { testField example { dateTime date time timestamp text bigInt decimal hashField array } project(where:{ OR: [{nameIn: ["Test"]}] }) { id name createdAt updatedAt active } projects(order: { name: DESC}, where: { active: true}) { active name id createdAt updatedAt } } mutation m{ createProject(data: { name: "Jhon" }) { id name } } ``` ## References https://graphql-ruby.org/queries/ast_analysis.html https://graphql-ruby.org/errors/error_handling https://github.com/rmosolgo/graphql-ruby/issues?q=is%3Aissue+circular+loading rmosolgo/graphql-ruby#2716 (comment) https://guides.rubyonrails.org/active_model_basics.html#securepassword # Tasks ☑️ - default rails new my_api --api - rails generate graphql:install - installing graphiql-rails in dev mode - installing mongoid - bootstrap graphoid - generate scalars and initial mongoid driver - hash scalar type - fix comments - add operators/attribute utils and grapho - generate basic queries - trying to process single query - basic find queries is working - fixing field not declared - enable basic model filters - make OR works - enable in and nin filters - plural queries is working but without eager load - enabling sorting and filter on plural queries - fixing and make works creates mutation - add delete mutations - add user model - add nested resolve one to result queries - add nested resolve many to result queries without filters - update roadmap on readme - enabling nested wheres - enabling bi directional relationships - fixing circular dependency with string type lazy declaration - enable mutations and sorter type - fixing circular dependency with string type lazy declaration - implementign nesting wheres - enabling graphield and fix operation with belongs to - fix query operators contains, regex, lt and etc - enable graphorbid - simple tests - tests passing - tests passing - add users with nested where tests - add tests for create user mutation - add tests for OR filters - Add references to readme - Reduce boilerplate to generate model queries and mutations - Reduce boilerplate to generate model queries and mutations - drop comments and remove xMeta support - drop comments and remove xMeta support - require all graphoid headers upfront - Migrating app files to spec/dummy - finalize migration to gem mode - bringing original specs - fix camelize operators - fix delete one spec - remove testes with create update delete many - fix camelize and underscore fields - fix camelize and underscore fields - fix operations matches with underscore new format for graphql - fix subqueries - actions tests - remove useless tests - change order - fix dummy app tests - Enable input nested arguments - fix camelcase for input arguments - deprecating sub query on has_one and belongs to because only one result is possible - include some, none and every operators - Fix tests on CI environemnts caused to to eager_load = true on rails config
- Loading branch information