@@ -18,9 +18,6 @@ def self.use(schema, dynamic: false, profiles: EmptyObjects::EMPTY_HASH, preload
1818 ctx . freeze
1919 }
2020 schema . visibility = self . new ( schema , dynamic : dynamic , preload : preload , profiles : profiles , migration_errors : migration_errors )
21- if preload
22- schema . visibility . preload
23- end
2421 end
2522
2623 def initialize ( schema , dynamic :, preload :, profiles :, migration_errors :)
@@ -43,6 +40,9 @@ def initialize(schema, dynamic:, preload:, profiles:, migration_errors:)
4340 @types = nil
4441 @all_references = nil
4542 @loaded_all = false
43+ if preload
44+ self . preload
45+ end
4646 end
4747
4848 def all_directives
@@ -153,12 +153,12 @@ def profile_for(context)
153153 visibility_profile = context [ :visibility_profile ]
154154 if @profiles . include? ( visibility_profile )
155155 profile_ctx = @profiles [ visibility_profile ]
156- @cached_profiles [ visibility_profile ] ||= @schema . visibility_profile_class . new ( name : visibility_profile , context : profile_ctx , schema : @schema )
156+ @cached_profiles [ visibility_profile ] ||= @schema . visibility_profile_class . new ( name : visibility_profile , context : profile_ctx , schema : @schema , visibility : self )
157157 elsif @dynamic
158158 if context . is_a? ( Query ::NullContext )
159159 top_level_profile
160160 else
161- @schema . visibility_profile_class . new ( context : context , schema : @schema )
161+ @schema . visibility_profile_class . new ( context : context , schema : @schema , visibility : self )
162162 end
163163 elsif !context . key? ( :visibility_profile )
164164 raise ArgumentError , "#{ @schema } expects a visibility profile, but `visibility_profile:` wasn't passed. Provide a `visibility_profile:` value or add `dynamic: true` to your visibility configuration."
@@ -168,7 +168,7 @@ def profile_for(context)
168168 elsif context . is_a? ( Query ::NullContext )
169169 top_level_profile
170170 else
171- @schema . visibility_profile_class . new ( context : context , schema : @schema )
171+ @schema . visibility_profile_class . new ( context : context , schema : @schema , visibility : self )
172172 end
173173 end
174174
@@ -181,7 +181,7 @@ def top_level_profile(refresh: false)
181181 if refresh
182182 @top_level_profile = nil
183183 end
184- @top_level_profile ||= @schema . visibility_profile_class . new ( context : Query ::NullContext . instance , schema : @schema )
184+ @top_level_profile ||= @schema . visibility_profile_class . new ( context : Query ::NullContext . instance , schema : @schema , visibility : self )
185185 end
186186
187187 private
0 commit comments