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

Fix graphql specification #68

Closed

Conversation

l-vincent-l
Copy link

@l-vincent-l l-vincent-l commented Dec 20, 2017

It wasn't respecting the graphql specification. So it couldn't be used
with standard GraphQL clients.

@l-vincent-l
Copy link
Author

What can I do so it can be merged?

@abyrd
Copy link

abyrd commented Jan 10, 2018

Hi @l-vincent-l, generally we just prefer to have more explanations and recorded connections between commits, PRs and issues. For example in this case, there is an issue conveyal/gtfs-lib#94 which in turn references conveyal/gtfs-api#17 and records the history of this problem being reported and observations about it. In it's current state there's no information in this PR nor in its commits about how the specification was not being respected, nor the fact that this resolves an open issue. We would usually try to include the issue number reference in the commit message and/or the pull request, and even repeat some explanation of what problem was being addressed (even if it's a shortened copy and paste from an issue).

It often also derails the review process when there's no statement of what the PR is meant to do or fix because there's no statement of a problem to check against.

I will provide a review.

Copy link

@abyrd abyrd left a comment

Choose a reason for hiding this comment

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

Please add a bit of explanation and "fixes #N" to the pull request and/or constituent commits. A few style/type issues have been marked inline.

String query = node.get("query").asText();
return doQuery(vars, query, response);
}

private static Object doQuery (String varsJson, String queryJson, Response response) {

private static Object doQuery (JsonNode varsJson, String queryJson, Response response) {
Copy link

Choose a reason for hiding this comment

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

The type of result.toSpecification() is Map<String, Object> so the most specific return type of this function is Map<String, Object>.

List<GraphQLError> errs = result.getErrors();
if (!errs.isEmpty()) {
response.status(400);
return result.toSpecification();
Copy link

Choose a reason for hiding this comment

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

The if and else clauses both contain the same final return statement, so should be factored out. Other than setting the response status to 400 the rest of the statements in both branches of this conditional are always useful. So I'd prefer to just do if (!errs.isEmpty()) response.status(400); and then fall through to always run what is currently in the else block.

It wasn't respecting the graphql specification. So it couldn't be used
with standard GraphQL clients.
@l-vincent-l
Copy link
Author

I change the PR according to @abyrd requests.
I'm not sure this PR will fix conveyal/gtfs-lib#94 or conveyal/gtfs-api#17 I never used this libraries in there standalone versions.

@abyrd
Copy link

abyrd commented Feb 5, 2018

Hi @l-vincent-l the only reason I haven't merged this is that it would require corresponding changes to our front end. I'll need to check with @landonreed to see how straightforward that will be. We're in the middle of testing the GTFS editor migration to RDBMS storage, so I'm not sure whether we'll have time to make that change for a few weeks.

@landonreed
Copy link
Member

@l-vincent-l, we should be able to include this in the next release. However, I would recommend that the base branch be dev instead of master. We're looking to only use master for releases. If you change the base branch, I will review the changes and merge if it looks good. I will then add a corresponding fix for https://github.com/catalogueglobal/datatools-ui.

@abyrd
Copy link

abyrd commented Apr 2, 2018

@Tristramg has rebased this against dev as #76. Closing.

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