Skip to content

Commit

Permalink
Fix serialization of Document (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryTsepelev authored May 14, 2024
1 parent 04f1de8 commit cf3a966
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## master

- [PR#77](https://github.com/DmitryTsepelev/graphql-ruby-persisted_queries/pull/77)
Fix serialization of Document (broken by [this change](https://github.com/rmosolgo/graphql-ruby/commit/7de7a1f98d4299abc1fb7deb5ca0ed2190867ab6)) ([@DmitryTsepelev][])

## 1.8.0 (2024-03-31)

- [PR#73](https://github.com/DmitryTsepelev/graphql-ruby-persisted_queries/pull/73)
Expand Down
22 changes: 22 additions & 0 deletions lib/graphql/persisted_queries/compiled_queries/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@ module CompiledQueries
class Resolver
include GraphQL::PersistedQueries::ResolverHelpers

# Patch to support custom serialization
class GraphQL::Language::Parser # rubocop:disable Style/ClassAndModuleChildren
SEP = "|"

def _dump(*)
[
@graphql_str,
JSON.generate("filename": @filename, "max_tokens": @max_tokens, "document": @document)
].join(SEP)
end

def self._load(args)
graphql_str, raw_kwargs = args.split(SEP)

new(graphql_str,
filename: raw_kwargs["filename"],
max_tokens: raw_kwargs["max_tokens"]).tap do |parser|
parser.instance_variable_set(:@document, raw_kwargs["document"])
end
end
end

def initialize(schema, extensions)
@schema = schema
@extensions = extensions
Expand Down

0 comments on commit cf3a966

Please sign in to comment.