File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -328,6 +328,16 @@ The above example will generate the following request::
328328 }
329329 }
330330
331+ Alternatively, you can use the DSL shortcut syntax to create a fragment by
332+ passing the string ``"fragment" `` directly to the :meth: `__call__ <gql.dsl.DSLSchema.__call__> ` method.
333+ When using the shortcut, you must also provide the fragment name via the ``name `` parameter::
334+
335+ name_and_appearances = (
336+ ds("fragment", "NameAndAppearances")
337+ .on(ds.Character)
338+ .select(ds.Character.name, ds.Character.appearsIn)
339+ )
340+
331341Inline Fragments
332342^^^^^^^^^^^^^^^^
333343
@@ -373,6 +383,14 @@ this can be written in a concise manner::
373383 DSLInlineFragment().on(ds.Human).select(ds.Human.homePlanet)
374384 )
375385
386+ Alternatively, you can use the DSL shortcut syntax to create an inline fragment by
387+ passing the string ``"..." `` directly to the :meth: `__call__ <gql.dsl.DSLSchema.__call__> ` method::
388+
389+ query_with_inline_fragment = ds.Query.hero.args(episode=6).select(
390+ ds.Character.name,
391+ ds("...")
392+ )
393+
376394Meta-fields
377395^^^^^^^^^^^
378396
@@ -384,6 +402,15 @@ you can use the :class:`DSLMetaField <gql.dsl.DSLMetaField>` class::
384402 DSLMetaField("__typename")
385403 )
386404
405+ Alternatively, you can use the DSL shortcut syntax to create the same meta-field by
406+ passing the ``"__typename" `` string directly to the :meth: `__call__ <gql.dsl.DSLSchema.__call__> ` method::
407+
408+ query = ds.Query.hero.select(
409+ ds.Character.name,
410+ ds("__typename")
411+ )
412+
413+
387414Directives
388415^^^^^^^^^^
389416
You can’t perform that action at this time.
0 commit comments