Package graphql.extensions
Class ExtensionsBuilder
- java.lang.Object
-
- graphql.extensions.ExtensionsBuilder
-
@PublicApi public class ExtensionsBuilder extends java.lang.Object
This class can be used to help build the graphql `extensions` map. A series of changes to the extensions can be added and these will be merged together via aExtensionsMerger
implementation and that resultant map can be used as the `extensions`The engine will place a
ExtensionsBuilder
into theGraphQLContext
(if one is not manually placed there) and henceDataFetcher
s can use it to build up extensions progressively.At the end of the execution, the
ExtensionsBuilder
will be used to build a graphql `extensions` map that is placed in theExecutionResult
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ExtensionsBuilder
addValue(@NotNull java.lang.Object key, @Nullable java.lang.Object value)
Adds a single new value into the extension builderExtensionsBuilder
addValues(@NotNull java.util.Map<java.lang.Object,java.lang.Object> newValues)
Adds new values into the extension builderjava.util.Map<java.lang.Object,java.lang.Object>
buildExtensions()
This builds an extensions map from this builder, merging together the values providedint
getChangeCount()
static ExtensionsBuilder
newExtensionsBuilder()
static ExtensionsBuilder
newExtensionsBuilder(ExtensionsMerger extensionsMerger)
This creates a new ExtensionsBuilder with the providedExtensionsMerger
ExecutionResult
setExtensions(ExecutionResult executionResult)
This sets new extensions into the providedExecutionResult
, overwriting any previous values
-
-
-
Method Detail
-
newExtensionsBuilder
public static ExtensionsBuilder newExtensionsBuilder()
- Returns:
- a new ExtensionsBuilder using a default merger
-
newExtensionsBuilder
public static ExtensionsBuilder newExtensionsBuilder(ExtensionsMerger extensionsMerger)
This creates a new ExtensionsBuilder with the providedExtensionsMerger
- Parameters:
extensionsMerger
- the merging code to use- Returns:
- a new ExtensionsBuilder using the provided merger
-
getChangeCount
public int getChangeCount()
- Returns:
- how many extension changes have been made so far
-
addValues
public ExtensionsBuilder addValues(@NotNull @NotNull java.util.Map<java.lang.Object,java.lang.Object> newValues)
Adds new values into the extension builder- Parameters:
newValues
- the new values to add- Returns:
- this builder for fluent style reasons
-
addValue
public ExtensionsBuilder addValue(@NotNull @NotNull java.lang.Object key, @Nullable @Nullable java.lang.Object value)
Adds a single new value into the extension builder- Parameters:
key
- the key in the extensionsvalue
- the value in the extensions- Returns:
- this builder for fluent style reasons
-
buildExtensions
public java.util.Map<java.lang.Object,java.lang.Object> buildExtensions()
This builds an extensions map from this builder, merging together the values provided- Returns:
- a new extensions map
-
setExtensions
public ExecutionResult setExtensions(ExecutionResult executionResult)
This sets new extensions into the providedExecutionResult
, overwriting any previous values- Parameters:
executionResult
- the result to set these extensions into- Returns:
- a new ExecutionResult with the extensions values in this builder
-
-