@@ -323,36 +323,35 @@ def __call__(
323
323
self , shortcut : Literal ["..." ]
324
324
) -> "DSLInlineFragment" : ... # pragma: no cover
325
325
326
- @overload
327
- def __call__ (
328
- self , shortcut : Literal ["fragment" ], name : str
329
- ) -> "DSLFragment" : ... # pragma: no cover
330
-
331
326
@overload
332
327
def __call__ (self , shortcut : Any ) -> "DSLDirective" : ... # pragma: no cover
333
328
334
329
def __call__ (
335
- self , shortcut : str , name : Optional [ str ] = None
336
- ) -> Union ["DSLMetaField" , "DSLInlineFragment" , "DSLFragment" , " DSLDirective" ]:
337
- """Factory method for creating DSL objects.
330
+ self , shortcut : str
331
+ ) -> Union ["DSLMetaField" , "DSLInlineFragment" , "DSLDirective" ]:
332
+ """Factory method for creating DSL objects from a shortcut string .
338
333
339
- Currently, supports creating DSLDirective instances when name starts with '@'.
340
- Future support planned for meta-fields (__typename), inline fragments (...),
341
- and fragment definitions (fragment).
334
+ The shortcut determines which DSL object is created:
342
335
343
- :param shortcut: the name of the object to create
336
+ * "__typename", "__schema", "__type" -> :class:`DSLMetaField`
337
+ * "..." -> :class:`DSLInlineFragment`
338
+ * "@<name>" -> :class:`DSLDirective`
339
+
340
+ :param shortcut: The shortcut string identifying the DSL object.
344
341
:type shortcut: str
345
342
346
- :return: :class:`DSLDirective` instance
343
+ :return: A DSL object corresponding to the given shortcut.
344
+ :rtype: DSLMetaField | DSLInlineFragment | DSLDirective
347
345
348
- :raises ValueError: if shortcut format is not supported
346
+ :raises ValueError: If the shortcut is not recognized.
349
347
"""
348
+
349
+ if shortcut in ("__typename" , "__schema" , "__type" ):
350
+ return DSLMetaField (name = shortcut )
351
+ if shortcut == "..." :
352
+ return DSLInlineFragment ()
350
353
if shortcut .startswith ("@" ):
351
354
return DSLDirective (name = shortcut [1 :], dsl_schema = self )
352
- # Future support:
353
- # if name.startswith("__"): return DSLMetaField(name)
354
- # if name == "...": return DSLInlineFragment()
355
- # if name.startswith("fragment "): return DSLFragment(name[9:])
356
355
357
356
raise ValueError (f"Unsupported shortcut: { shortcut } " )
358
357
0 commit comments