@@ -323,36 +323,35 @@ def __call__(
323323 self , shortcut : Literal ["..." ]
324324 ) -> "DSLInlineFragment" : ... # pragma: no cover
325325
326- @overload
327- def __call__ (
328- self , shortcut : Literal ["fragment" ], name : str
329- ) -> "DSLFragment" : ... # pragma: no cover
330-
331326 @overload
332327 def __call__ (self , shortcut : Any ) -> "DSLDirective" : ... # pragma: no cover
333328
334329 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 .
338333
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:
342335
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.
344341 :type shortcut: str
345342
346- :return: :class:`DSLDirective` instance
343+ :return: A DSL object corresponding to the given shortcut.
344+ :rtype: DSLMetaField | DSLInlineFragment | DSLDirective
347345
348- :raises ValueError: if shortcut format is not supported
346+ :raises ValueError: If the shortcut is not recognized.
349347 """
348+
349+ if shortcut in ("__typename" , "__schema" , "__type" ):
350+ return DSLMetaField (name = shortcut )
351+ if shortcut == "..." :
352+ return DSLInlineFragment ()
350353 if shortcut .startswith ("@" ):
351354 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:])
356355
357356 raise ValueError (f"Unsupported shortcut: { shortcut } " )
358357
0 commit comments