@@ -191,7 +191,7 @@ remoteSchemaInterface schemaDoc defn@(G.InterfaceTypeDefinition description name
191
191
P. memoizeOn 'remoteSchemaObject defn do
192
192
subFieldParsers <- traverse (remoteField' schemaDoc) fields
193
193
objs :: [Parser 'Output n () ] <-
194
- traverse (getObject >=> remoteSchemaObject schemaDoc) possibleTypes
194
+ traverse (getObject schemaDoc name >=> remoteSchemaObject schemaDoc) possibleTypes
195
195
-- In the Draft GraphQL spec (> June 2018), interfaces can themselves
196
196
-- implement superinterfaces. In the future, we may need to support this
197
197
-- here.
@@ -202,15 +202,6 @@ remoteSchemaInterface schemaDoc defn@(G.InterfaceTypeDefinition description name
202
202
-- should have a check that expresses that that collection of objects is equal
203
203
-- to 'possibelTypes'.
204
204
pure $ void $ P. selectionSetInterface name description subFieldParsers objs
205
- where
206
- getObject :: G. Name -> m G. ObjectTypeDefinition
207
- getObject objectName =
208
- onNothing (lookupObject schemaDoc objectName) $
209
- case lookupInterface schemaDoc objectName of
210
- Nothing -> throw400 RemoteSchemaError $ " Could not find type " <> squote objectName
211
- <> " , which is defined as a member type of Union " <> squote name
212
- Just _ -> throw400 RemoteSchemaError $ " Union type " <> squote name <>
213
- " can only include object types. It cannot include " <> squote objectName
214
205
215
206
-- | 'remoteSchemaUnion' returns a output parser for a given 'UnionTypeDefinition'.
216
207
remoteSchemaUnion
@@ -221,20 +212,25 @@ remoteSchemaUnion
221
212
-> m (Parser 'Output n () )
222
213
remoteSchemaUnion schemaDoc defn@ (G. UnionTypeDefinition description name _directives objectNames) =
223
214
P. memoizeOn 'remoteSchemaObject defn do
224
- objDefs <- traverse getObject objectNames
215
+ objDefs <- traverse ( getObject schemaDoc name) objectNames
225
216
objs :: [Parser 'Output n () ] <- traverse (remoteSchemaObject schemaDoc) objDefs
226
217
when (null objs) $
227
218
throw400 RemoteSchemaError $ " List of member types cannot be empty for union type " <> squote name
228
219
pure $ void $ P. selectionSetUnion name description objs
229
- where
230
- getObject :: G. Name -> m G. ObjectTypeDefinition
231
- getObject objectName =
232
- onNothing (lookupObject schemaDoc objectName) $
233
- case lookupInterface schemaDoc objectName of
234
- Nothing -> throw400 RemoteSchemaError $ " Could not find type " <> squote objectName
235
- <> " , which is defined as a member type of Union " <> squote name
236
- Just _ -> throw400 RemoteSchemaError $ " Union type " <> squote name <>
237
- " can only include object types. It cannot include " <> squote objectName
220
+
221
+ getObject
222
+ :: MonadError QErr m
223
+ => SchemaIntrospection
224
+ -> G. Name
225
+ -> G. Name
226
+ -> m G. ObjectTypeDefinition
227
+ getObject schemaDoc name objectName =
228
+ onNothing (lookupObject schemaDoc objectName) $
229
+ case lookupInterface schemaDoc objectName of
230
+ Nothing -> throw400 RemoteSchemaError $ " Could not find type " <> squote objectName
231
+ <> " , which is defined as a member type of " <> squote name
232
+ Just _ -> throw400 RemoteSchemaError $ " Type " <> squote name <>
233
+ " can only include object types. It cannot include " <> squote objectName
238
234
239
235
-- | remoteSchemaInputObject returns an input parser for a given 'G.InputObjectTypeDefinition'
240
236
remoteSchemaInputObject
0 commit comments