Skip to content

Commit

Permalink
Add a deprecation warning when .request is returned
Browse files Browse the repository at this point in the history
  • Loading branch information
rmosolgo committed Jan 25, 2024
1 parent 930468f commit 24138c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/graphql/dataloader/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ def initialize(source, key)
def load
@source.load(@key)
end

def load_with_deprecation_warning
warn("Returning `.request(...)` from GraphQL::Dataloader is deprecated, use `.load(...)` instead. (See usage of #{@source} with #{@key.inspect}).")
load
end
end
end
end
2 changes: 1 addition & 1 deletion lib/graphql/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,7 @@ def lazy_methods
else
@lazy_methods = GraphQL::Execution::Lazy::LazyMethodMap.new
@lazy_methods.set(GraphQL::Execution::Lazy, :value)
@lazy_methods.set(GraphQL::Dataloader::Request, :load)
@lazy_methods.set(GraphQL::Dataloader::Request, :load_with_deprecation_warning)
end
end
@lazy_methods
Expand Down

0 comments on commit 24138c7

Please sign in to comment.