File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
src/main/java/graphql/schema Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -80,10 +80,34 @@ public interface DataFetchingEnvironment {
8080
8181
8282 /**
83- * @return the list of fields currently in query context
83+ * It can happen that a query has overlapping fields which are
84+ * are querying the same data. If this is the case they get merged
85+ * together and fetched only once, but this method returns all of the Fields
86+ * from the query.
87+ *
88+ * Most of the time you probably want to use {@link #getField()}.
89+ *
90+ * Example query with more than one Field returned:
91+ *
92+ * query Foo {
93+ * bar
94+ * ...BarFragment
95+ * }
96+ *
97+ * fragment BarFragment on Query {
98+ * bar
99+ * }
100+ *
101+ *
102+ * @return the list of fields currently queried
84103 */
85104 List <Field > getFields ();
86105
106+ /**
107+ * @return returns the field which is currently queried. See also {@link #getFields()}
108+ */
109+ Field getField ();
110+
87111 /**
88112 * @return graphql type of the current field
89113 */
Original file line number Diff line number Diff line change @@ -83,6 +83,11 @@ public List<Field> getFields() {
8383 return fields ;
8484 }
8585
86+ @ Override
87+ public Field getField () {
88+ return fields .get (0 );
89+ }
90+
8691 @ Override
8792 public GraphQLOutputType getFieldType () {
8893 return fieldType ;
You can’t perform that action at this time.
0 commit comments