Skip to content

ExecutionResult follows spec - #480

Closed
guy120494 wants to merge 8 commits into
graphql-java:masterfrom
guy120494:master
Closed

guy120494 wants to merge 8 commits into
graphql-java:masterfrom
guy120494:master

Conversation

@guy120494

@guy120494 guy120494 commented May 31, 2017 •

Copy link
Copy Markdown
Contributor

implemented @bbakerman idea to issue #473 and added a toMap() method.

(and also added generics to StaticDataFethcer)

@guy120494 guy120494 changed the title added generics to StaticDataFetcher Response follows spec May 31, 2017
@guy120494 guy120494 changed the title Response follows spec ExecutionResult follows spec May 31, 2017
@guy120494 guy120494 closed this May 31, 2017
@guy120494 guy120494 reopened this May 31, 2017

@bbakerman bbakerman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming changes would be great

Map<Object,Object> getExtensions();
Map<Object, Object> getExtensions();

ExecutionResult toMap();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we call this toSpecification() please

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with Javadoc

}


private static class ExecutionResultWithoutErrors implements ExecutionResult {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@guy120494

Copy link
Copy Markdown
Contributor Author

changed names and added Javadoc to toSpecification()

@andimarek andimarek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bbakerman your thoughts about extensions?

List<GraphQLError> getErrors();

Map<Object,Object> getExtensions();
Map<Object, Object> getExtensions();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should remove this: graphql-java doesn't support it currently and ExecutionResult should be immutable imho.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I use extension in my work, so I prefer to leave it as it is.
Also, I think it is better not to delete it and maybe do a //TODO.
About the immutable, it is better to do it immutable after graphql-java supports extension, that way people that do use extensions (like me) don't need to make another instance.

But even if you think I'm wrong, I think it's for another PR, don't you?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guy120494 could you describe your use case? thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, In my work we construct our own object to be sent as a response, so we don't use this getExtensions() method.
Nevertheless, make a PR that supports extensions is better than delete this method and maybe forget about it later in the future.

But again, I think this discussion belongs to another PR, because this is not the topic about this PR as i see it. If you want me to remove this method an accept this PR, I would be happy to do so

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andimarek - the spec says:

The

response map may also contain an entry with key extensions. This entry, if set, must have a map as its value. This entry is reserved for implementors to extend the protocol however they see fit, and hence there are no additional restrictions on its contents.

So since graphql-java (the implementor) does not use it then I would remove it until some one comes up with a good use case for it.

And perhaps we should have a ExecutionResultBuilder so that it ExecutionResult can be immutable more easily

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bbakerman yes, this is what I meant: it is reserved for the server implementation do something with it and currently we don't use it. And on top of that it is just strange to have such a map, but it never used.

@guy120494 Thanks for your feedback. I agree it is a separate PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is now addressed here: #484

guy120494 added 2 commits June 5, 2017 18:59
# Conflicts:
#	src/main/java/graphql/ExecutionResult.java
#	src/main/java/graphql/ExecutionResultImpl.java
#	src/main/java/graphql/execution/ExecutionStrategyParameters.java
#	src/main/java/graphql/execution/instrumentation/parameters/InstrumentationDataFetchParameters.java
#	src/main/java/graphql/execution/instrumentation/parameters/InstrumentationExecutionParameters.java
#	src/main/java/graphql/execution/instrumentation/parameters/InstrumentationFieldFetchParameters.java
#	src/main/java/graphql/execution/instrumentation/parameters/InstrumentationFieldParameters.java
#	src/main/java/graphql/execution/instrumentation/parameters/InstrumentationValidationParameters.java
@guy120494

Copy link
Copy Markdown
Contributor Author

can this PR be merged? or do I need to fix anything else?

@andimarek

Copy link
Copy Markdown
Member

@guy120494 sorry for the delay.

I get the idea that we should make it easy to conform to the spec, but in general we don't support any specific json libraries.

I think the best thing would be to just return a real Map with errors missing, if none happened. @bbakerman your thoughts?

@guy120494

Copy link
Copy Markdown
Contributor Author

@andimarek but all JSON libraries respect the "transient" keyword, don't they?
So we don't restrict ourselves to a specific library

@andimarek

Copy link
Copy Markdown
Member

@guy120494 yes, but I think a Map would be just be easier: there is no need for any real class here.

@bbakerman

Copy link
Copy Markdown
Member

Closing and re-implenting via #552

@bbakerman bbakerman closed this Jul 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants