★ wanayoo — archive 1999 https://github.com/graphql-java/graphql-java/pull/1355Nouvelle recherche | Portail wanayoo
Skip to content
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

Added the ability to instrument document and variables #1355

Conversation

@bbakerman
Copy link
Member

@bbakerman bbakerman commented Dec 20, 2018

This tweaks the unreleased ability to instrument a Document and turns it into Document and variables

Copy link
Member

@andimarek andimarek left a comment •

see the comment about preventing mutations to variables

return document;
}

public Map<String, Object> getVariables() {

This comment has been minimized.

@andimarek

andimarek Dec 20, 2018
Member

return a new linkedhasmap here I would say

This comment has been minimized.

@tsroka

tsroka Dec 20, 2018
Member

I would say, return Collections.unmodifiableMap here, since this class is supposed to be immutable?

This comment has been minimized.

@andimarek

andimarek Dec 27, 2018
Member

I agree in theory both are valid options, but in graphql java we decided to return new copies everywhere.

This comment has been minimized.

@bbakerman

bbakerman Jan 8, 2019
Author Member

fixed

return new PreparsedDocumentEntry(toInvalidSyntaxError(parseResult.getException()));
} else {
final Document document = parseResult.getDocument();
// they may have changed the document and the variables via instrumentation so update the reference to it
executionInput = executionInput.transform(builder -> builder.variables(parseResult.getVariables()));

This comment has been minimized.

@tsroka

tsroka Dec 20, 2018
Member

AFAIK any other instrumentation methods cannot change state. instrumentDocumentAndVariables feels inconsistent with the rest of Instrumentation interface. Should it not be a separate interface with Transformation in its name?

This comment has been minimized.

@bbakerman

bbakerman Jan 8, 2019
Author Member

Actually we have 6 - instrumentExecutionInput, DocumentAndVariables, Schema, ExecutionContext, DataFetcher, and ExecutionResult

return document;
}

public Map<String, Object> getVariables() {

This comment has been minimized.

@tsroka

tsroka Dec 20, 2018
Member

I would say, return Collections.unmodifiableMap here, since this class is supposed to be immutable?

@andimarek andimarek added this to the 12.0 milestone Dec 27, 2018
@bbakerman bbakerman merged commit 8aaada8 into graphql-java:master Jan 8, 2019
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.