private CompletableFuture<Publisher<Object>> createSourceEventStream(ExecutionContext executionContext, ExecutionStrategyParameters parameters) { ExecutionStrategyParameters newParameters = firstFieldOfSubscriptionSelection(parameters); CompletableFuture<FetchedValue> fieldFetched = fetchField(executionContext, newParameters); return fieldFetched.thenApply(fetchedValue -> { Object publisher = fetchedValue.getFetchedValue(); if (publisher != null) { assertTrue(publisher instanceof Publisher, "You data fetcher must return a Publisher of events when using graphql subscriptions"); } //noinspection unchecked return (Publisher<Object>) publisher; }); }
private CompletableFuture<ExecutionResult> executeSubscriptionEvent(ExecutionContext executionContext, ExecutionStrategyParameters parameters, Object eventPayload) { ExecutionContext newExecutionContext = executionContext.transform(builder -> builder.root(eventPayload)); ExecutionStrategyParameters newParameters = firstFieldOfSubscriptionSelection(parameters); FetchedValue fetchedValue = FetchedValue.newFetchedValue().fetchedValue(eventPayload) .rawFetchedValue(eventPayload) .localContext(parameters.getLocalContext()) .build(); return completeField(newExecutionContext, newParameters, fetchedValue).getFieldValue() .thenApply(executionResult -> wrapWithRootFieldName(newParameters, executionResult)); }
private CompletableFuture<Publisher<Object>> createSourceEventStream(ExecutionContext executionContext, ExecutionStrategyParameters parameters) { ExecutionStrategyParameters newParameters = firstFieldOfSubscriptionSelection(parameters); CompletableFuture<FetchedValue> fieldFetched = fetchField(executionContext, newParameters); return fieldFetched.thenApply(fetchedValue -> { Object publisher = fetchedValue.getFetchedValue(); if (publisher != null) { assertTrue(publisher instanceof Publisher, "You data fetcher must return a Publisher of events when using graphql subscriptions"); } //noinspection unchecked return (Publisher<Object>) publisher; }); }
private CompletableFuture<ExecutionResult> executeSubscriptionEvent(ExecutionContext executionContext, ExecutionStrategyParameters parameters, Object eventPayload) { ExecutionContext newExecutionContext = executionContext.transform(builder -> builder.root(eventPayload)); ExecutionStrategyParameters newParameters = firstFieldOfSubscriptionSelection(parameters); FetchedValue fetchedValue = FetchedValue.newFetchedValue().fetchedValue(eventPayload) .rawFetchedValue(eventPayload) .localContext(parameters.getLocalContext()) .build(); return completeField(newExecutionContext, newParameters, fetchedValue).getFieldValue() .thenApply(executionResult -> wrapWithRootFieldName(newParameters, executionResult)); }