@Test public void testArrayStartsWith() throws Exception { GraphQLObjectType innerType = newObject() .name("Inner") .field(newStringField("b").staticValue("foo")) .build(); GraphQLSchema schema = newQuerySchema(it -> it .field( newField("a", new GraphQLList(innerType)) .dataFetcher(env -> Flowable .just(asList(true, true, true)) .delay(1, SECONDS, scheduler) .startWith(new ArrayList<Boolean>()) ) ) ); ExecutionResult executionResult = new GraphQL(schema, strategy).execute("{ a { b } }"); Flowable.fromPublisher((Publisher<Change>) executionResult.getData()).timestamp(scheduler).subscribe(subscriber); scheduler.advanceTimeBy(2, SECONDS); subscriber .assertChanges(it -> it.containsExactly( tuple("00:000", "", ImmutableMap.of("a", emptyList())), tuple("01:000", "a", asList(ImmutableMap.of("b", "foo"), ImmutableMap.of("b", "foo"), ImmutableMap.of("b", "foo"))), tuple("01:000", "a[1]", ImmutableMap.of("b", "foo")), tuple("01:000", "a[2]", ImmutableMap.of("b", "foo")) )) .assertComplete(); }
@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);  }