Skip to content

Commit 8378a40

Browse files
author
Nathaniel Woodthorpe
authored
Merge pull request #30 from haines/frozen-string-literals
Frozen string literals
2 parents 1ee0a2f + 89e0842 commit 8378a40

File tree

8 files changed

+21
-3
lines changed

8 files changed

+21
-3
lines changed

graphql-remote_loader.gemspec

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# coding: utf-8
2+
# frozen_string_literal: true
3+
24
lib = File.expand_path('../lib', __FILE__)
35
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
46
require 'graphql/remote_loader/version'

lib/graphql/remote_loader.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "graphql"
24
require "graphql/batch"
35

lib/graphql/remote_loader/loader.rb

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "prime"
24
require "json"
35
require_relative "query_merger"
@@ -19,9 +21,7 @@ def self.load(query, context: {}, variables: {})
1921

2022
store_context(context)
2123

22-
interpolate_variables!(query, variables)
23-
24-
self.for.load([query, prime, @context])
24+
self.for.load([interpolate_variables(query, variables), prime, @context])
2525
end
2626

2727
# Loads the value, then if the query was successful, fulfills promise with
@@ -97,6 +97,10 @@ def perform(queries_and_primes)
9797
# E.g.
9898
# interpolate_variables("foo(bar: $my_var)", { my_var: "buzz" })
9999
# => "foo(bar: \"buzz\")"
100+
def self.interpolate_variables(query, variables = {})
101+
query.dup.tap { |mutable_query| interpolate_variables!(mutable_query, variables) }
102+
end
103+
100104
def self.interpolate_variables!(query, variables = {})
101105
variables.each do |variable, value|
102106
case value

lib/graphql/remote_loader/query_merger.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module GraphQL
24
module RemoteLoader
35
# Given a list of queries and their prime UIDs, generate the merged and labeled

lib/graphql/remote_loader/version.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module GraphQL
24
module RemoteLoader
35
VERSION = "1.0.5"

spec/spec_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'bundler/setup'
24
Bundler.setup
35

spec/unit/lib/graphql/remote_loader/loader_spec.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "spec_helper"
24

35
class TestLoader < GraphQL::RemoteLoader::Loader

spec/unit/lib/graphql/remote_loader/query_merger_spec.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "spec_helper"
24

35
describe GraphQL::RemoteLoader::QueryMerger do

0 commit comments

Comments
 (0)