Class DataFetchingEnvironment

java.lang.Object
com.codename1.backend.graphql.DataFetchingEnvironment

public final class DataFetchingEnvironment extends Object

What a DataFetcher is given: the parent value, the field's arguments and the request's context.

Arguments are already coerced to the schema's types: an Int is an Integer, a Float a Double, an ID a String, an enum the value's name, an input object a Map and a list a List. Use Json.convert(Object, Class) to read a map into a class of the application's own.

  • Method Details

    • getSource

      public Object getSource()
      The parent value, from which this field is resolved; null on a root field unless the execution was given a root value.
    • getArgument

      public Object getArgument(String name)
      One argument, or null when it was neither given nor defaulted.
    • containsArgument

      public boolean containsArgument(String name)
      Whether the client gave the argument -- as null too -- or the schema defaulted it.
    • getArguments

      public Map<String,Object> getArguments()
      Every argument, by name.
    • getArgumentAsJson

      public Object getArgumentAsJson(String name)
      One argument as its JSON tree -- whole numbers as Long, objects as maps -- the form the generated JSON codecs read a class of the application's own from. Null when the argument is absent.
    • getArgumentsAsJson

      public Object getArgumentsAsJson()
      Every argument as one JSON object tree; see getArgumentAsJson(String).
    • getContext

      public Object getContext()
      The context the request was executed with: the HttpServer.Request when it came over HTTP or WebSocket, unless the program supplied its own.
    • getFieldName

      public String getFieldName()
      The field's name in the schema, not its alias.
    • getParentTypeName

      public String getParentTypeName()
      The name of the object type the field belongs to.
    • getExecutionPath

      public List<Object> getExecutionPath()
      Where the field is in the response, as names and list indexes.
    • getVariables

      public Map<String,Object> getVariables()
      The operation's coerced variables.