diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index acc28473a8c..86a1a8e7653 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -4,3 +4,6 @@ # project-wide reformatting with prettier 9c9dd613489a348d2381acdcbeab8f86589154d7 +# graphql test and documentation reformatting with prettier +12c51f44f204db31d34a1eeb0d59204226e0fa5d + diff --git a/docs/apis/GraphQL-Tutorial.md b/docs/apis/GraphQL-Tutorial.md index e8bf41032b9..bfc87813f1d 100644 --- a/docs/apis/GraphQL-Tutorial.md +++ b/docs/apis/GraphQL-Tutorial.md @@ -32,17 +32,18 @@ GraphQL query in the left hand panel of the page: ```graphql { - routes { - longName - shortName - gtfsId - agency { - gtfsId - name - } - mode + routes { + longName + shortName + gtfsId + agency { + gtfsId + name } + mode + } } + ``` @@ -69,64 +70,59 @@ Most people want to get routing results out of OTP, so lets see the query for th ```graphql { - plan( - # these coordinates are in Portland, change this to YOUR origin - from: { lat: 45.5552, lon: -122.6534 } - # these coordinates are in Portland, change this to YOUR destination - to: { lat: 45.4908, lon: -122.5519 } - # use the correct date and time of your request - date: "2023-02-15", - time: "11:37", - # choose the transport modes you need - transportModes: [ - { - mode: WALK - }, - { - mode: TRANSIT - }, - ]) { - itineraries { - start - end - legs { - mode - from { - name - lat - lon - departure { - scheduledTime - estimated { - time - delay - } - } - } - to { - name - lat - lon - arrival { - scheduledTime - estimated { - time - delay - } - } - } - route { - gtfsId - longName - shortName - } - legGeometry { - points - } + plan( + # these coordinates are in Portland, change this to YOUR origin + from: { lat: 45.5552, lon: -122.6534 } + # these coordinates are in Portland, change this to YOUR destination + to: { lat: 45.4908, lon: -122.5519 } + # use the correct date and time of your request + date: "2023-02-15" + time: "11:37" + # choose the transport modes you need + transportModes: [{ mode: WALK }, { mode: TRANSIT }] + ) { + itineraries { + start + end + legs { + mode + from { + name + lat + lon + departure { + scheduledTime + estimated { + time + delay } + } } + to { + name + lat + lon + arrival { + scheduledTime + estimated { + time + delay + } + } + } + route { + gtfsId + longName + shortName + } + legGeometry { + points + } + } } + } } + ``` diff --git a/pom.xml b/pom.xml index 6f202b592f8..f055c2abd0e 100644 --- a/pom.xml +++ b/pom.xml @@ -429,6 +429,7 @@ src/test/java/**/*.java src/ext/java/**/*.java src/ext-test/java/**/*.java + src/test/resources/org/opentripplanner/apis/**/*.graphql diff --git a/src/test/resources/org/opentripplanner/apis/gtfs/queries/alerts.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/alerts.graphql index 923d9f027cb..33ff47dd33b 100644 --- a/src/test/resources/org/opentripplanner/apis/gtfs/queries/alerts.graphql +++ b/src/test/resources/org/opentripplanner/apis/gtfs/queries/alerts.graphql @@ -1,18 +1,18 @@ { - alerts { - id - alertHeaderText - alertDescriptionText - alertUrl - # these translations are a bit questionable, the above fields are already translated into the - # language selected in the request - alertDescriptionTextTranslations { - language - text - } - alertHeaderTextTranslations { - text - language - } + alerts { + id + alertHeaderText + alertDescriptionText + alertUrl + # these translations are a bit questionable, the above fields are already translated into the + # language selected in the request + alertDescriptionTextTranslations { + language + text } -} \ No newline at end of file + alertHeaderTextTranslations { + text + language + } + } +} diff --git a/src/test/resources/org/opentripplanner/apis/gtfs/queries/feedinfo.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/feedinfo.graphql index 68516d26237..b9f47c3c68a 100644 --- a/src/test/resources/org/opentripplanner/apis/gtfs/queries/feedinfo.graphql +++ b/src/test/resources/org/opentripplanner/apis/gtfs/queries/feedinfo.graphql @@ -1,12 +1,12 @@ { - feeds { - agencies { - name - url - } - publisher { - name - url - } + feeds { + agencies { + name + url } -} \ No newline at end of file + publisher { + name + url + } + } +} diff --git a/src/test/resources/org/opentripplanner/apis/gtfs/queries/nearest.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/nearest.graphql index 3616ec03ff8..c7f8eed4213 100644 --- a/src/test/resources/org/opentripplanner/apis/gtfs/queries/nearest.graphql +++ b/src/test/resources/org/opentripplanner/apis/gtfs/queries/nearest.graphql @@ -3,15 +3,15 @@ edges { node { place { - ...on Stop { + ... on Stop { + id + gtfsId + parentStation { id - gtfsId - parentStation { - id - } } } } } } - } \ No newline at end of file + } +} diff --git a/src/test/resources/org/opentripplanner/apis/gtfs/queries/patterns.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/patterns.graphql index 32be856274e..090473cfc7a 100644 --- a/src/test/resources/org/opentripplanner/apis/gtfs/queries/patterns.graphql +++ b/src/test/resources/org/opentripplanner/apis/gtfs/queries/patterns.graphql @@ -1,43 +1,43 @@ { - patterns { - code - headsign - trips { - gtfsId - stoptimes { - stop { - gtfsId - name - } - headsign - scheduledArrival - scheduledDeparture - stopPosition - realtimeState - pickupType - dropoffType - } - occupancy { - occupancyStatus - } + patterns { + code + headsign + trips { + gtfsId + stoptimes { + stop { + gtfsId + name } - vehiclePositions { - vehicleId - label - lat - lon - stopRelationship { - status - stop { - gtfsId - } - } - speed - heading - lastUpdated - trip { - gtfsId - } + headsign + scheduledArrival + scheduledDeparture + stopPosition + realtimeState + pickupType + dropoffType + } + occupancy { + occupancyStatus + } + } + vehiclePositions { + vehicleId + label + lat + lon + stopRelationship { + status + stop { + gtfsId } + } + speed + heading + lastUpdated + trip { + gtfsId + } } -} \ No newline at end of file + } +} diff --git a/src/test/resources/org/opentripplanner/apis/gtfs/queries/plan-extended.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/plan-extended.graphql index bcd96892e84..76bf8aa84e0 100644 --- a/src/test/resources/org/opentripplanner/apis/gtfs/queries/plan-extended.graphql +++ b/src/test/resources/org/opentripplanner/apis/gtfs/queries/plan-extended.graphql @@ -1,161 +1,157 @@ { - plan( - from: { lat: 52.3092, lon: 13.0291 } - to: { lat: 52.5147, lon: 13.3927 } - date: "2023-02-15", - time: "11:37", - parking: { - unpreferredCost: 555, - preferred: [{ not: [{tags: ["a", "b", "c"]}] }], - filters: [{ select: [{tags:["e"]}] }] - }, - transportModes: [ - { - mode: CAR, - qualifier: HAIL + plan( + from: { lat: 52.3092, lon: 13.0291 } + to: { lat: 52.5147, lon: 13.3927 } + date: "2023-02-15" + time: "11:37" + parking: { + unpreferredCost: 555 + preferred: [{ not: [{ tags: ["a", "b", "c"] }] }] + filters: [{ select: [{ tags: ["e"] }] }] + } + transportModes: [{ mode: CAR, qualifier: HAIL }] + ) { + itineraries { + start + end + # next two are deprecated + startTime + endTime + generalizedCost + accessibilityScore + emissionsPerPerson { + co2 + } + numberOfTransfers + walkDistance + walkTime + legs { + mode + start { + scheduledTime + estimated { + time + delay + } + } + end { + scheduledTime + estimated { + time + delay + } + } + from { + name + lat + lon + arrival { + scheduledTime + estimated { + delay + time + } + } + departure { + scheduledTime + estimated { + delay + time + } + } + departureTime + arrivalTime + } + to { + name + lat + lon + arrival { + scheduledTime + estimated { + delay + time + } + } + departure { + scheduledTime + estimated { + delay + time } - ]) { - itineraries { - start - end - # next two are deprecated - startTime - endTime - generalizedCost - accessibilityScore - emissionsPerPerson { - co2 + } + departureTime + arrivalTime + } + startTime + endTime + mode + generalizedCost + headsign + trip { + tripHeadsign + } + intermediatePlaces { + arrival { + scheduledTime + estimated { + time + delay + } + } + departure { + scheduledTime + estimated { + time + delay + } + } + stop { + name + } + } + alerts { + id + alertHeaderText + alertDescriptionText + alertEffect + alertCause + alertSeverityLevel + alertUrl + effectiveStartDate + effectiveEndDate + entities { + ... on Stop { + name + gtfsId + lat + lon + } + } + } + rideHailingEstimate { + provider { + id + } + productName + minPrice { + currency { + code + digits } - numberOfTransfers - walkDistance - walkTime - legs { - mode - start { - scheduledTime - estimated { - time - delay - } - } - end { - scheduledTime - estimated { - time - delay - } - } - from { - name - lat - lon - arrival { - scheduledTime - estimated { - delay - time - } - } - departure { - scheduledTime - estimated { - delay - time - } - } - departureTime - arrivalTime - } - to { - name - lat - lon - arrival { - scheduledTime - estimated { - delay - time - } - } - departure { - scheduledTime - estimated { - delay - time - } - } - departureTime - arrivalTime - } - startTime - endTime - mode - generalizedCost - headsign - trip { - tripHeadsign - } - intermediatePlaces { - arrival { - scheduledTime - estimated { - time - delay - } - } - departure { - scheduledTime - estimated { - time - delay - } - } - stop { - name - } - } - alerts { - id - alertHeaderText - alertDescriptionText - alertEffect - alertCause - alertSeverityLevel - alertUrl - effectiveStartDate - effectiveEndDate - entities { - ... on Stop { - name - gtfsId - lat - lon - } - } - } - rideHailingEstimate { - provider { - id - } - productName - minPrice { - currency { - code - digits - } - amount - } - maxPrice { - currency { - code - digits - } - amount - } - arrival - } - accessibilityScore + amount + } + maxPrice { + currency { + code + digits } + amount + } + arrival } + accessibilityScore + } } -} \ No newline at end of file + } +} diff --git a/src/test/resources/org/opentripplanner/apis/gtfs/queries/plan-fares.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/plan-fares.graphql index 0c2ba29dce5..c5081b1c8ed 100644 --- a/src/test/resources/org/opentripplanner/apis/gtfs/queries/plan-fares.graphql +++ b/src/test/resources/org/opentripplanner/apis/gtfs/queries/plan-fares.graphql @@ -1,71 +1,71 @@ { - plan( - from: { lat: 52.3092, lon: 13.0291 } - to: { lat: 52.5147, lon: 13.3927 } - date: "2023-02-15", - time: "11:37", - transportModes: [{ mode: TRANSIT }] - ) { - itineraries { - legs { - mode - from { - name - lat - lon - departureTime - arrivalTime - } - to { - name - lat - lon - departureTime - arrivalTime - } - startTime - endTime - mode - generalizedCost - fareProducts { - id - product { - id - name - __typename - ... on DefaultFareProduct { - price { - currency { - digits - code - } - amount - } - } - riderCategory { - id - name - } - medium { - id - name - } - } + plan( + from: { lat: 52.3092, lon: 13.0291 } + to: { lat: 52.5147, lon: 13.3927 } + date: "2023-02-15" + time: "11:37" + transportModes: [{ mode: TRANSIT }] + ) { + itineraries { + legs { + mode + from { + name + lat + lon + departureTime + arrivalTime + } + to { + name + lat + lon + departureTime + arrivalTime + } + startTime + endTime + mode + generalizedCost + fareProducts { + id + product { + id + name + __typename + ... on DefaultFareProduct { + price { + currency { + digits + code } + amount + } } - fares { - type - cents - currency - components { - currency - cents - fareId - routes { - gtfsId - } - } + riderCategory { + id + name + } + medium { + id + name } + } + } + } + fares { + type + cents + currency + components { + currency + cents + fareId + routes { + gtfsId + } } + } } -} \ No newline at end of file + } +} diff --git a/src/test/resources/org/opentripplanner/apis/gtfs/queries/plan-stop-positions.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/plan-stop-positions.graphql index 4e0e42e4b57..dd2217e4288 100644 --- a/src/test/resources/org/opentripplanner/apis/gtfs/queries/plan-stop-positions.graphql +++ b/src/test/resources/org/opentripplanner/apis/gtfs/queries/plan-stop-positions.graphql @@ -1,48 +1,43 @@ { - plan( - fromPlace: "from", - toPlace: "to", - date: "2023-02-15", - time: "11:37" - ){ - itineraries { - startTime - endTime - generalizedCost - accessibilityScore - legs { - mode - from { - name - lat - lon - departureTime - arrivalTime - stopPosition { - __typename - ... on PositionAtStop { - position - } - } - } - to { - name - lat - lon - departureTime - arrivalTime - stopPosition { - __typename - ... on PositionAtStop { - position - } - } - } - startTime - endTime - mode - generalizedCost + plan(fromPlace: "from", toPlace: "to", date: "2023-02-15", time: "11:37") { + itineraries { + startTime + endTime + generalizedCost + accessibilityScore + legs { + mode + from { + name + lat + lon + departureTime + arrivalTime + stopPosition { + __typename + ... on PositionAtStop { + position } + } } + to { + name + lat + lon + departureTime + arrivalTime + stopPosition { + __typename + ... on PositionAtStop { + position + } + } + } + startTime + endTime + mode + generalizedCost + } } -} \ No newline at end of file + } +} diff --git a/src/test/resources/org/opentripplanner/apis/gtfs/queries/plan-tutorial.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/plan-tutorial.graphql index 39877eef0b7..dd461060029 100644 --- a/src/test/resources/org/opentripplanner/apis/gtfs/queries/plan-tutorial.graphql +++ b/src/test/resources/org/opentripplanner/apis/gtfs/queries/plan-tutorial.graphql @@ -1,59 +1,53 @@ { - plan( - # these coordinates are in Portland, change this to YOUR origin - from: { lat: 45.5552, lon: -122.6534 } - # these coordinates are in Portland, change this to YOUR destination - to: { lat: 45.4908, lon: -122.5519 } - # use the correct date and time of your request - date: "2023-02-15", - time: "11:37", - # choose the transport modes you need - transportModes: [ - { - mode: WALK - }, - { - mode: TRANSIT - }, - ]) { - itineraries { - start - end - legs { - mode - from { - name - lat - lon - departure { - scheduledTime - estimated { - time - delay - } - } - } - to { - name - lat - lon - arrival { - scheduledTime - estimated { - time - delay - } - } - } - route { - gtfsId - longName - shortName - } - legGeometry { - points - } + plan( + # these coordinates are in Portland, change this to YOUR origin + from: { lat: 45.5552, lon: -122.6534 } + # these coordinates are in Portland, change this to YOUR destination + to: { lat: 45.4908, lon: -122.5519 } + # use the correct date and time of your request + date: "2023-02-15" + time: "11:37" + # choose the transport modes you need + transportModes: [{ mode: WALK }, { mode: TRANSIT }] + ) { + itineraries { + start + end + legs { + mode + from { + name + lat + lon + departure { + scheduledTime + estimated { + time + delay } + } } + to { + name + lat + lon + arrival { + scheduledTime + estimated { + time + delay + } + } + } + route { + gtfsId + longName + shortName + } + legGeometry { + points + } + } } -} \ No newline at end of file + } +} diff --git a/src/test/resources/org/opentripplanner/apis/gtfs/queries/planConnection.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/planConnection.graphql index 4013479ded0..5691f130119 100644 --- a/src/test/resources/org/opentripplanner/apis/gtfs/queries/planConnection.graphql +++ b/src/test/resources/org/opentripplanner/apis/gtfs/queries/planConnection.graphql @@ -1,26 +1,14 @@ { planConnection( - dateTime: { - earliestDeparture: "2023-06-13T14:30+03:00" - } + dateTime: { earliestDeparture: "2023-06-13T14:30+03:00" } searchWindow: "PT2H30M" first: 5 origin: { - location: { - coordinate: { - latitude: 45.5552 - longitude: -122.6534 - } - } + location: { coordinate: { latitude: 45.5552, longitude: -122.6534 } } label: "Home" } destination: { - location: { - coordinate: { - latitude: 45.4908 - longitude: -122.5519 - } - } + location: { coordinate: { latitude: 45.4908, longitude: -122.5519 } } label: "Work" } modes: { @@ -31,25 +19,11 @@ access: [BICYCLE_RENTAL, WALK] transfer: [WALK] egress: [BICYCLE_RENTAL, WALK] - transit: [ - { - mode: TRAM - cost: { - reluctance: 1.3 - } - }, - { - mode: BUS - } - ] + transit: [{ mode: TRAM, cost: { reluctance: 1.3 } }, { mode: BUS }] } } preferences: { - accessibility: { - wheelchair: { - enabled: true - } - } + accessibility: { wheelchair: { enabled: true } } street: { car: { reluctance: 6.5 @@ -59,70 +33,36 @@ } parking: { unpreferredCost: 200 - preferred: [{ - select: [{ - tags: ["best-park"] - }] - }] - filters: [{ - not: [{ - tags: ["worst-park"] - }] - }] + preferred: [{ select: [{ tags: ["best-park"] }] }] + filters: [{ not: [{ tags: ["worst-park"] }] }] } } bicycle: { reluctance: 3.0 speed: 7.4 - optimization: { - type: SAFEST_STREETS - } + optimization: { type: SAFEST_STREETS } boardCost: 200 walk: { speed: 1.3 - cost: { - mountDismountCost: 100 - reluctance: 3.5 - } + cost: { mountDismountCost: 100, reluctance: 3.5 } mountDismountTime: "PT5S" } rental: { - destinationBicyclePolicy: { - allowKeeping: true - keepingCost: 300 - } + destinationBicyclePolicy: { allowKeeping: true, keepingCost: 300 } allowedNetworks: ["foo", "bar"] bannedNetworks: ["foobar"] } parking: { unpreferredCost: 200 - preferred: [{ - select: [{ - tags: ["best-park"] - }] - }] - filters: [{ - not: [{ - tags: ["worst-park"] - }] - }] + preferred: [{ select: [{ tags: ["best-park"] }] }] + filters: [{ not: [{ tags: ["worst-park"] }] }] } } - walk: { - speed: 2.4 - reluctance: 1.5 - safetyFactor: 0.5 - boardCost: 200 - } + walk: { speed: 2.4, reluctance: 1.5, safetyFactor: 0.5, boardCost: 200 } } transit: { - board: { - waitReluctance: 3.2 - slack: "PT1M30S" - } - alight: { - slack: "PT0S" - } + board: { waitReluctance: 3.2, slack: "PT1M30S" } + alight: { slack: "PT0S" } transfer: { cost: 200 slack: "PT2M" @@ -160,4 +100,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/test/resources/org/opentripplanner/apis/gtfs/queries/routes-extended.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/routes-extended.graphql index 50d89980442..90972cfa8cd 100644 --- a/src/test/resources/org/opentripplanner/apis/gtfs/queries/routes-extended.graphql +++ b/src/test/resources/org/opentripplanner/apis/gtfs/queries/routes-extended.graphql @@ -1,14 +1,14 @@ { - routes { - longName - shortName - gtfsId - agency { - gtfsId - name - } - mode - sortOrder - bikesAllowed + routes { + longName + shortName + gtfsId + agency { + gtfsId + name } -} \ No newline at end of file + mode + sortOrder + bikesAllowed + } +} diff --git a/src/test/resources/org/opentripplanner/apis/gtfs/queries/routes-tutorial.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/routes-tutorial.graphql index 66d7f370c3f..6e948d2d5f8 100644 --- a/src/test/resources/org/opentripplanner/apis/gtfs/queries/routes-tutorial.graphql +++ b/src/test/resources/org/opentripplanner/apis/gtfs/queries/routes-tutorial.graphql @@ -1,12 +1,12 @@ { - routes { - longName - shortName - gtfsId - agency { - gtfsId - name - } - mode + routes { + longName + shortName + gtfsId + agency { + gtfsId + name } -} \ No newline at end of file + mode + } +} diff --git a/src/test/resources/org/opentripplanner/apis/gtfs/queries/stops.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/stops.graphql index f5de224ebfd..5f3df71f8e7 100644 --- a/src/test/resources/org/opentripplanner/apis/gtfs/queries/stops.graphql +++ b/src/test/resources/org/opentripplanner/apis/gtfs/queries/stops.graphql @@ -1,9 +1,9 @@ { - stops { - gtfsId - lat - lon - name - vehicleMode - } -} \ No newline at end of file + stops { + gtfsId + lat + lon + name + vehicleMode + } +} diff --git a/src/test/resources/org/opentripplanner/apis/gtfs/queries/vehicle-parking.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/vehicle-parking.graphql index 4eda1fae456..324d7aff5d6 100644 --- a/src/test/resources/org/opentripplanner/apis/gtfs/queries/vehicle-parking.graphql +++ b/src/test/resources/org/opentripplanner/apis/gtfs/queries/vehicle-parking.graphql @@ -1,6 +1,6 @@ { - vehicleParkings { - name - vehicleParkingId - } -} \ No newline at end of file + vehicleParkings { + name + vehicleParkingId + } +} diff --git a/src/test/resources/org/opentripplanner/apis/gtfs/queries/walk-steps.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/walk-steps.graphql index d7d8f116745..c88958840d4 100644 --- a/src/test/resources/org/opentripplanner/apis/gtfs/queries/walk-steps.graphql +++ b/src/test/resources/org/opentripplanner/apis/gtfs/queries/walk-steps.graphql @@ -1,23 +1,20 @@ { - plan( - fromPlace: "from", - toPlace: "to", - date: "2023-02-15", - time: "11:37", - transportModes: [ - { - mode: WALK - } - ]) { - itineraries { - legs { - steps { - streetName - area - relativeDirection - absoluteDirection - } - } + plan( + fromPlace: "from" + toPlace: "to" + date: "2023-02-15" + time: "11:37" + transportModes: [{ mode: WALK }] + ) { + itineraries { + legs { + steps { + streetName + area + relativeDirection + absoluteDirection } + } } -} \ No newline at end of file + } +}