-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DO NOT MERGE : This POC shows what a new GraphQLEngine might look like #3348
Open
bbakerman
wants to merge
7
commits into
master
Choose a base branch
from
engine-support
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fe3e6e9
This POC shows what a new GraphQLEnginemight look like
bbakerman 0c72be8
This POC shows what a new GraphQLEngine might look like - fixed ES tests
bbakerman fd29fd6
This POC shows what a new GraphQLEngine might look like - tweaked met…
bbakerman 07e8be1
This POC shows what a new GraphQLEngine might look like - oops
bbakerman dfaccf1
This POC shows what a new GraphQLEngine might look like - Insturmenta…
bbakerman bbc278b
This POC shows what a new GraphQLEngine might look like - Insturmenta…
bbakerman acff3a7
This POC shows what a new GraphQLEngine might look like - Insturmenta…
bbakerman File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
package graphql.engine; | ||
|
||
import graphql.Assert; | ||
import graphql.Internal; | ||
import graphql.PublicApi; | ||
import graphql.execution.ExecutionStepInfo; | ||
import graphql.execution.MergedField; | ||
import graphql.execution.MergedSelectionSet; | ||
import graphql.execution.NonNullableFieldValidator; | ||
import graphql.execution.ResultPath; | ||
import graphql.language.OperationDefinition; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import static graphql.Assert.assertNotNull; | ||
|
||
/** | ||
* The parameters that are passed to {@link GraphQLEngine}s | ||
*/ | ||
@PublicApi | ||
public class EngineParameters { | ||
private final ExecutionStepInfo executionStepInfo; | ||
private final Object source; | ||
private final Object localContext; | ||
private final MergedSelectionSet fields; | ||
private final NonNullableFieldValidator nonNullableFieldValidator; | ||
private final ResultPath path; | ||
private final MergedField currentField; | ||
private final OperationDefinition.Operation operation; | ||
|
||
private EngineParameters(Builder builder) { | ||
|
||
this.executionStepInfo = assertNotNull(builder.executionStepInfo, () -> "executionStepInfo is null"); | ||
this.localContext = builder.localContext; | ||
this.fields = assertNotNull(builder.fields, () -> "fields is null"); | ||
this.source = builder.source; | ||
this.nonNullableFieldValidator = builder.nonNullableFieldValidator; | ||
this.path = builder.path; | ||
this.currentField = builder.currentField; | ||
this.operation = builder.operation; | ||
} | ||
|
||
public NonNullableFieldValidator getNonNullableFieldValidator() { | ||
return nonNullableFieldValidator; | ||
} | ||
|
||
public OperationDefinition.Operation getOperation() { | ||
return operation; | ||
} | ||
|
||
public ExecutionStepInfo getExecutionStepInfo() { | ||
return executionStepInfo; | ||
} | ||
|
||
public Object getSource() { | ||
return source; | ||
} | ||
|
||
public MergedSelectionSet getFields() { | ||
return fields; | ||
} | ||
|
||
public NonNullableFieldValidator getNonNullFieldValidator() { | ||
return nonNullableFieldValidator; | ||
} | ||
|
||
public ResultPath getPath() { | ||
return path; | ||
} | ||
|
||
public Object getLocalContext() { | ||
return localContext; | ||
} | ||
|
||
/** | ||
* This returns the current field in its query representations. | ||
* | ||
* @return the current merged fields | ||
*/ | ||
public MergedField getField() { | ||
return currentField; | ||
} | ||
|
||
public EngineParameters transform(Consumer<Builder> builderConsumer) { | ||
Builder builder = newParameters(this); | ||
builderConsumer.accept(builder); | ||
return builder.build(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("EngineParameters { path=%s, executionStepInfo=%s, source=%s, fields=%s }", | ||
path, executionStepInfo, source, fields); | ||
} | ||
|
||
public static Builder newParameters() { | ||
return new Builder(); | ||
} | ||
|
||
public static Builder newParameters(EngineParameters oldParameters) { | ||
return new Builder(oldParameters); | ||
} | ||
|
||
@Internal | ||
public static class Builder { | ||
ExecutionStepInfo executionStepInfo; | ||
Object source; | ||
Object localContext; | ||
MergedSelectionSet fields; | ||
NonNullableFieldValidator nonNullableFieldValidator; | ||
ResultPath path = ResultPath.rootPath(); | ||
MergedField currentField; | ||
OperationDefinition.Operation operation; | ||
|
||
/** | ||
* @see EngineParameters#newParameters() | ||
*/ | ||
private Builder() { | ||
} | ||
|
||
/** | ||
* @see EngineParameters#newParameters(EngineParameters) | ||
*/ | ||
private Builder(EngineParameters oldParameters) { | ||
this.executionStepInfo = oldParameters.executionStepInfo; | ||
this.source = oldParameters.source; | ||
this.localContext = oldParameters.localContext; | ||
this.fields = oldParameters.fields; | ||
this.nonNullableFieldValidator = oldParameters.nonNullableFieldValidator; | ||
this.currentField = oldParameters.currentField; | ||
this.path = oldParameters.path; | ||
this.operation = oldParameters.operation; | ||
} | ||
|
||
public Builder executionStepInfo(ExecutionStepInfo executionStepInfo) { | ||
this.executionStepInfo = executionStepInfo; | ||
return this; | ||
} | ||
|
||
public Builder executionStepInfo(ExecutionStepInfo.Builder executionStepInfoBuilder) { | ||
this.executionStepInfo = executionStepInfoBuilder.build(); | ||
return this; | ||
} | ||
|
||
public Builder fields(MergedSelectionSet fields) { | ||
this.fields = fields; | ||
return this; | ||
} | ||
|
||
public Builder field(MergedField currentField) { | ||
this.currentField = currentField; | ||
return this; | ||
} | ||
|
||
public Builder source(Object source) { | ||
this.source = source; | ||
return this; | ||
} | ||
|
||
public Builder localContext(Object localContext) { | ||
this.localContext = localContext; | ||
return this; | ||
} | ||
|
||
public Builder nonNullFieldValidator(NonNullableFieldValidator nonNullableFieldValidator) { | ||
this.nonNullableFieldValidator = Assert.assertNotNull(nonNullableFieldValidator, () -> "requires a NonNullValidator"); | ||
return this; | ||
} | ||
|
||
public Builder path(ResultPath path) { | ||
this.path = path; | ||
return this; | ||
} | ||
|
||
public Builder operation(OperationDefinition.Operation operation) { | ||
this.operation = operation; | ||
return this; | ||
} | ||
|
||
public EngineParameters build() { | ||
return new EngineParameters(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package graphql.engine; | ||
|
||
import graphql.ExecutionResult; | ||
import graphql.execution.ExecutionContext; | ||
import graphql.execution.NonNullableFieldWasNullException; | ||
import graphql.execution.instrumentation.Instrumentation; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
public interface GraphQLEngine { | ||
|
||
Instrumentation getInstrumentation(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instrumentation is engine specific - it has to be |
||
|
||
CompletableFuture<ExecutionResult> execute(ExecutionContext executionContext, EngineParameters parameters) throws NonNullableFieldWasNullException; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty much a copy of ExecutionStrategyParameters but I felt that is too tied to the old ES way