@@ -21,13 +21,15 @@ public class RuntimeWiring {
2121 private final Map <String , Map <String , DataFetcher >> dataFetchers ;
2222 private final Map <String , GraphQLScalarType > scalars ;
2323 private final Map <String , TypeResolver > typeResolvers ;
24+ private Map <String , EnumValuesProvider > enumValuesProviders ;
2425 private final WiringFactory wiringFactory ;
2526
26- private RuntimeWiring (Map <String , Map <String , DataFetcher >> dataFetchers , Map <String , GraphQLScalarType > scalars , Map <String , TypeResolver > typeResolvers , WiringFactory wiringFactory ) {
27+ private RuntimeWiring (Map <String , Map <String , DataFetcher >> dataFetchers , Map <String , GraphQLScalarType > scalars , Map <String , TypeResolver > typeResolvers , Map < String , EnumValuesProvider > enumValuesProviders , WiringFactory wiringFactory ) {
2728 this .dataFetchers = dataFetchers ;
2829 this .scalars = scalars ;
2930 this .typeResolvers = typeResolvers ;
3031 this .wiringFactory = wiringFactory ;
32+ this .enumValuesProviders = enumValuesProviders ;
3133 }
3234
3335 public Map <String , GraphQLScalarType > getScalars () {
@@ -46,6 +48,10 @@ public Map<String, TypeResolver> getTypeResolvers() {
4648 return typeResolvers ;
4749 }
4850
51+ public Map <String , EnumValuesProvider > getEnumValuesProviders () {
52+ return this .enumValuesProviders ;
53+ }
54+
4955 public WiringFactory getWiringFactory () {
5056 return wiringFactory ;
5157 }
@@ -62,6 +68,7 @@ public static class Builder {
6268 private final Map <String , Map <String , DataFetcher >> dataFetchers = new LinkedHashMap <>();
6369 private final Map <String , GraphQLScalarType > scalars = new LinkedHashMap <>();
6470 private final Map <String , TypeResolver > typeResolvers = new LinkedHashMap <>();
71+ private final Map <String , EnumValuesProvider > enumValuesProviders = new LinkedHashMap <>();
6572 private WiringFactory wiringFactory = new NoopWiringFactory ();
6673
6774 private Builder () {
@@ -72,7 +79,6 @@ private Builder() {
7279 * Adds a wiring factory into the runtime wiring
7380 *
7481 * @param wiringFactory the wiring factory to add
75- *
7682 * @return this outer builder
7783 */
7884 public Builder wiringFactory (WiringFactory wiringFactory ) {
@@ -85,7 +91,6 @@ public Builder wiringFactory(WiringFactory wiringFactory) {
8591 * This allows you to add in new custom Scalar implementations beyond the standard set.
8692 *
8793 * @param scalarType the new scalar implementation
88- *
8994 * @return the runtime wiring builder
9095 */
9196 public Builder scalar (GraphQLScalarType scalarType ) {
@@ -97,7 +102,6 @@ public Builder scalar(GraphQLScalarType scalarType) {
97102 * This allows you to add a new type wiring via a builder
98103 *
99104 * @param builder the type wiring builder to use
100- *
101105 * @return this outer builder
102106 */
103107 public Builder type (TypeRuntimeWiring .Builder builder ) {
@@ -109,7 +113,6 @@ public Builder type(TypeRuntimeWiring.Builder builder) {
109113 *
110114 * @param typeName the name of the type to wire
111115 * @param builderFunction a function that will be given the builder to use
112- *
113116 * @return the runtime wiring builder
114117 */
115118 public Builder type (String typeName , UnaryOperator <TypeRuntimeWiring .Builder > builderFunction ) {
@@ -121,7 +124,6 @@ public Builder type(String typeName, UnaryOperator<TypeRuntimeWiring.Builder> bu
121124 * This adds a type wiring
122125 *
123126 * @param typeRuntimeWiring the new type wiring
124- *
125127 * @return the runtime wiring builder
126128 */
127129 public Builder type (TypeRuntimeWiring typeRuntimeWiring ) {
@@ -133,14 +135,19 @@ public Builder type(TypeRuntimeWiring typeRuntimeWiring) {
133135 if (typeResolver != null ) {
134136 this .typeResolvers .put (typeName , typeResolver );
135137 }
138+
139+ EnumValuesProvider enumValuesProvider = typeRuntimeWiring .getEnumValuesProvider ();
140+ if (enumValuesProvider != null ) {
141+ this .enumValuesProviders .put (typeName , enumValuesProvider );
142+ }
136143 return this ;
137144 }
138145
139146 /**
140147 * @return the built runtime wiring
141148 */
142149 public RuntimeWiring build () {
143- return new RuntimeWiring (dataFetchers , scalars , typeResolvers , wiringFactory );
150+ return new RuntimeWiring (dataFetchers , scalars , typeResolvers , enumValuesProviders , wiringFactory );
144151 }
145152
146153 }
0 commit comments