@Test public void testAnyPublisher() throws Exception { Duration tick = Duration.ofSeconds(1); GraphQLSchema schema = newQuerySchema(it -> it .field(newLongField("a").dataFetcher(env -> Flux.interval(tick).take(2))) ); ExecutionResult executionResult = new GraphQL(schema, strategy).execute("{ a }"); StepVerifier.withVirtualTime(() -> (Publisher<Change>) executionResult.getData()) .expectSubscription() .expectNoEvent(tick) .assertNext(matchChange("", ImmutableMap.of("a", 0L))) .expectNoEvent(tick) .assertNext(matchChange("a", 1L)) .verifyComplete(); }
@Override public ExecutionResult execute(ExecutionContext context, ExecutionParameters parameters) throws NonNullableFieldWasNullException { Map<String, List<Field>> fields = parameters.fields(); Object source = parameters.source(); return complexChangesFlow( context, source, __ -> fields.entrySet().stream(), (entry, sourceValue) -> resolveField( new ReactiveContext(context, entry.getKey()), transformParametersSource(parameters, source == null ? null : sourceValue), entry.getValue() ), results -> { Map<Object, Object> result = new HashMap<>(); for (Object entry : results) { result.put(((SimpleEntry) entry).getKey(), ((SimpleEntry) entry).getValue()); } return result; } ); }
ReactiveExecutionStrategy extends ExecutionStrategy { @Override public ExecutionResult execute(ExecutionContext context, ExecutionParameters parameters) throws NonNullableFieldWasNullException { Map<String, List<Field>> fields = parameters.fields(); Object source = parameters.source(); return complexChangesFlow( context, source, __ -> fields.entrySet().stream(), (entry, sourceValue) -> resolveField( new ReactiveContext(context, entry.getKey()), transformParametersSource(parameters, source == null ? null : sourceValue), entry.getValue() ), results -> { Map<Object, Object> result = new HashMap<>(); for (Object entry : results) { result.put(((SimpleEntry) entry).getKey(), ((SimpleEntry) entry).getValue()); } return result; } ); } }
ReactiveExecutionStrategy extends ExecutionStrategy { @Override public ExecutionResult execute(ExecutionContext context, ExecutionParameters parameters) throws NonNullableFieldWasNullException { Map<String, List<Field>> fields = parameters.fields(); Object source = parameters.source(); return complexChangesFlow( context, source, __ -> fields.entrySet().stream(), (entry, sourceValue) -> resolveField( new ReactiveContext(context, entry.getKey()), transformParametersSource(parameters, source == null ? null : sourceValue), entry.getValue() ), results -> { Map<Object, Object> result = new HashMap<>(); for (Object entry : results) { result.put(((SimpleEntry) entry).getKey(), ((SimpleEntry) entry).getValue()); } return result; } ); }  }
ReactiveExecutionStrategy extends ExecutionStrategy { @Override public ExecutionResult execute(ExecutionContext context, ExecutionParameters parameters) throws NonNullableFieldWasNullException { Map<String, List<Field>> fields = parameters.fields(); Object source = parameters.source(); return complexChangesFlow( context, source, __ -> fields.entrySet().stream(), (entry, sourceValue) -> resolveField( new ReactiveContext(context, entry.getKey()), transformParametersSource(parameters, source == null ? null : sourceValue), entry.getValue() ), results -> { Map<Object, Object> result = new HashMap<>(); for (Object entry : results) { result.put(((SimpleEntry) entry).getKey(), ((SimpleEntry) entry).getValue()); } return result; } ); }  @Override ExecutionResult execute(ExecutionContext context, ExecutionParameters parameters); }
ReactiveExecutionStrategy extends ExecutionStrategy { @Override public ExecutionResult execute(ExecutionContext context, ExecutionParameters parameters) throws NonNullableFieldWasNullException { Map<String, List<Field>> fields = parameters.fields(); Object source = parameters.source(); return complexChangesFlow( context, source, __ -> fields.entrySet().stream(), (entry, sourceValue) -> resolveField( new ReactiveContext(context, entry.getKey()), transformParametersSource(parameters, source == null ? null : sourceValue), entry.getValue() ), results -> { Map<Object, Object> result = new HashMap<>(); for (Object entry : results) { result.put(((SimpleEntry) entry).getKey(), ((SimpleEntry) entry).getValue()); } return result; } ); }  @Override ExecutionResult execute(ExecutionContext context, ExecutionParameters parameters);  }