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::
328
328
}
329
329
}
330
330
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
+
331
341
Inline Fragments
332
342
^^^^^^^^^^^^^^^^
333
343
@@ -373,6 +383,14 @@ this can be written in a concise manner::
373
383
DSLInlineFragment().on(ds.Human).select(ds.Human.homePlanet)
374
384
)
375
385
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
+
376
394
Meta-fields
377
395
^^^^^^^^^^^
378
396
@@ -384,6 +402,15 @@ you can use the :class:`DSLMetaField <gql.dsl.DSLMetaField>` class::
384
402
DSLMetaField("__typename")
385
403
)
386
404
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
+
387
414
Directives
388
415
^^^^^^^^^^
389
416
You can’t perform that action at this time.
0 commit comments