Should DgsDataFetchingEnvironment or DataFetchingEnvironment be used as query/mutation argument? #624
-
This might be a kind of dumb question but, while reading the docs, I've noticed that in some query and mutation examples, sometimes a DgsDataFetchingEnvironment is passed as method argument and some others pass a DataFetchingEnvironment. Just wanted to know which is the scenario or advantage to pass the implementation instead of the interface. Links to the docs to better explain my question:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Any suggestions? |
Beta Was this translation helpful? Give feedback.
-
The I find myself defaulting to |
Beta Was this translation helpful? Give feedback.
The
DataFetchingEnvironment
comes from thegraphql-java
Library. The DGS framework extends it to add some convenience methods.If you don’t need the convenience methods, it really doesn’t matter which one you use.
Whichever type you use, it will receive the same instance at runtime.
I find myself defaulting to
DgsDataFetchingEnvironment
most of the time, but haven’t been very consistent about it.