forked from ConsultingMD/graphql-preload
-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
Edit: see my next comment for the fix and subsequent problem/observation.
Howdy! Thanks a bunch for forking this into the future. I expect once I get it working it'll be a huge lifesaver.
I'm running into a wee problem where it's as if the preloading is not doing anything. I have a pretty minimal reproduction as I'm just playing around with a new Rails app.
rails6.0.2.2graphql1.10.5graphql-batch0.4.2graphql-preloadEnvek/graphql-preload@5040f7851bca3ce1044f8171b8301a2784720505
Schema
class ExampleSchema < GraphQL::Schema
use GraphQL::Batch
enable_preloading
mutation(Types::MutationType)
query(Types::QueryType)
# Opt in to the new runtime (default in future graphql-ruby versions)
use GraphQL::Execution::Interpreter
use GraphQL::Analysis::AST
# Add built-in connections for pagination
use GraphQL::Pagination::Connections
endModels
class Author < ApplicationRecord
has_many :posts
end
class Post < ApplicationRecord
belongs_to :author
endTypes
module Types
class AuthorType < Types::BaseObject
field :name, String, null: false
field :posts, [PostType], null: false, preload: :posts
# ^^^^^^^^^^^^^^^
end
class PostType < Types::BaseObject
field :title, String, null: true
field :author, AuthorType, null: true
field :author_id, ID, null: false
field :body, String, null: true
field :title, String, null: true
end
endQuery type
module Types
class QueryType < Types::BaseObject
field :authors, [AuthorType], null: true
def authors
Author.all
end
end
endHowever, making the following query succeeds, but still leads to a bunch of N+1s:
{
authors {
name
posts {
title
}
}
}Is there anything I might be missing? I tried to bring it perfectly in line with the test cases in this repo, and went over the README a few times.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
