-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: set up GraphQL API #18
Merged
Merged
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
7ffe1ee
fix: make env file work with direnv
boringcactus a56cb91
feat: pull in stop API client from dotcom
boringcactus 5162e10
feat: set up GraphQL API
boringcactus a0ab59d
chore: generate Credo config
boringcactus dd8d17c
fix: appease Credo
boringcactus 22b4e66
fix: appease Dialyzer
boringcactus 98fede8
feat: bring in Stops.Repo from dotcom
boringcactus 5a75e6e
appease Credo again
boringcactus aa3dbd2
test: bring in dotcom/stops tests
boringcactus b015c3e
ci: load example environment for mix test
boringcactus 959dd32
load sample environment more directly
boringcactus e7ce73b
don't run repo tests against real API
boringcactus e1dbbc3
add GraphQL test
boringcactus 750807a
use snapshot of real data for GraphQL test
boringcactus 4673e41
remove non-canonical route patterns
boringcactus 67bf135
remove doors, nodes, and fare vending machines
boringcactus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export API_KEY= | ||
#export API_KEY= | ||
export API_URL=https://api-dev.mbtace.com/ |
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,47 @@ | ||
defmodule MobileAppBackendWeb.SchemaTest do | ||
use MobileAppBackendWeb.ConnCase | ||
|
||
@stop_query """ | ||
query { | ||
stop(id: "place-boyls") { | ||
id | ||
name | ||
routes { | ||
id | ||
name | ||
routePatterns { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
} | ||
""" | ||
|
||
test "query: stop", %{conn: conn} do | ||
conn = | ||
post(conn, "/graphql", %{ | ||
"query" => @stop_query | ||
}) | ||
|
||
assert %{"data" => %{"stop" => stop_data}} = json_response(conn, 200) | ||
assert %{"id" => "place-boyls", "name" => "Boylston", "routes" => routes} = stop_data | ||
|
||
routes = Enum.sort_by(routes, & &1["id"]) | ||
|
||
assert routes |> Enum.map(& &1["id"]) == [ | ||
"Green-B", | ||
"Green-C", | ||
"Green-D", | ||
"Green-E" | ||
] | ||
|
||
assert %{ | ||
"id" => "Green-B", | ||
"name" => "Green Line B", | ||
"routePatterns" => route_patterns | ||
} = hd(routes) | ||
|
||
assert length(route_patterns) > 0 | ||
end | ||
end |
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.
question (non-blocking): Can the data be mocked for this test?
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.
It can, but there's a lot of data in the real response, and I'm not sure which parts would and would not be reasonable to elide from the real response.
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.
It looks like a lot of parts can be elided without breaking the test, though.