├── src ├── global.json ├── .nuke │ ├── parameters.json │ └── build.schema.json ├── GraphQLinq.Generated │ ├── SuperChargers │ │ ├── Node.cs │ │ ├── Region.cs │ │ ├── Email.cs │ │ ├── Phone.cs │ │ ├── LocationType.cs │ │ ├── Country.cs │ │ └── Location.cs │ ├── HSL │ │ ├── Node.cs │ │ ├── debugOutput.cs │ │ ├── LocationType.cs │ │ ├── BikesAllowed.cs │ │ ├── WheelchairBoarding.cs │ │ ├── Coordinates.cs │ │ ├── LegGeometry.cs │ │ ├── serviceTimeRange.cs │ │ ├── TranslatedString.cs │ │ ├── PickupDropoffType.cs │ │ ├── PlaceInterface.cs │ │ ├── RealtimeState.cs │ │ ├── VertexType.cs │ │ ├── stopAtDistanceEdge.cs │ │ ├── placeAtDistanceEdge.cs │ │ ├── FilterPlaceType.cs │ │ ├── OptimizeType.cs │ │ ├── stopAtDistance.cs │ │ ├── placeAtDistance.cs │ │ ├── StoptimesInPattern.cs │ │ ├── stopAtDistanceConnection.cs │ │ ├── placeAtDistanceConnection.cs │ │ ├── PageInfo.cs │ │ ├── fare.cs │ │ ├── fareComponent.cs │ │ ├── Mode.cs │ │ ├── Cluster.cs │ │ ├── BikePark.cs │ │ ├── DepartureRow.cs │ │ ├── CarPark.cs │ │ ├── Place.cs │ │ ├── Plan.cs │ │ ├── Itinerary.cs │ │ ├── Agency.cs │ │ ├── BikeRentalStation.cs │ │ ├── Pattern.cs │ │ ├── Alert.cs │ │ ├── Route.cs │ │ ├── Stoptime.cs │ │ ├── Leg.cs │ │ ├── Trip.cs │ │ ├── Stop.cs │ │ └── QueryType.cs │ ├── SpaceX │ │ ├── Users_constraint.cs │ │ ├── Conflict_action.cs │ │ ├── Result.cs │ │ ├── Users_select_column.cs │ │ ├── Users_update_column.cs │ │ ├── LaunchTelemetry.cs │ │ ├── Mass.cs │ │ ├── Order_by.cs │ │ ├── Force.cs │ │ ├── DragonPressurizedCapsule.cs │ │ ├── Distance.cs │ │ ├── CoreMission.cs │ │ ├── LaunchRocketFirstStage.cs │ │ ├── ShipMission.cs │ │ ├── Volume.cs │ │ ├── CapsuleMission.cs │ │ ├── ShipsResult.cs │ │ ├── MissionResult.cs │ │ ├── RocketsResult.cs │ │ ├── ShipLocation.cs │ │ ├── HistoriesResult.cs │ │ ├── RocketLandingLegs.cs │ │ ├── DragonTrunk.cs │ │ ├── LaunchesPastResult.cs │ │ ├── DragonTrunkCargo.cs │ │ ├── LaunchRocketSecondStage.cs │ │ ├── Users_aggregate.cs │ │ ├── Link.cs │ │ ├── Users_mutation_response.cs │ │ ├── Address.cs │ │ ├── Users_on_conflict.cs │ │ ├── LaunchSite.cs │ │ ├── Users_obj_rel_insert_input.cs │ │ ├── RocketSecondStagePayloadCompositeFairing.cs │ │ ├── Users_arr_rel_insert_input.cs │ │ ├── RocketSecondStagePayloads.cs │ │ ├── Users_aggregate_fields.cs │ │ ├── Location.cs │ │ ├── RocketPayloadWeight.cs │ │ ├── Users_aggregate_order_by.cs │ │ ├── HistoryFind.cs │ │ ├── InfoLinks.cs │ │ ├── MissionsFind.cs │ │ ├── Users_max_fields.cs │ │ ├── Users_min_fields.cs │ │ ├── DragonHeatShield.cs │ │ ├── LaunchRocketFairings.cs │ │ ├── Users_max_order_by.cs │ │ ├── Users_min_order_by.cs │ │ ├── Users.cs │ │ ├── Users_order_by.cs │ │ ├── Users_set_input.cs │ │ ├── Users_insert_input.cs │ │ ├── DragonThrust.cs │ │ ├── RocketSecondStage.cs │ │ ├── QueryExtensions.cs │ │ ├── RocketFirstStage.cs │ │ ├── History.cs │ │ ├── CapsulesFind.cs │ │ ├── LaunchRocket.cs │ │ ├── Capsule.cs │ │ ├── Mission.cs │ │ ├── Uuid_comparison_exp.cs │ │ ├── Landpad.cs │ │ ├── Launchpad.cs │ │ ├── Users_bool_exp.cs │ │ ├── LaunchRocketFirstStageCore.cs │ │ ├── Timestamptz_comparison_exp.cs │ │ ├── RocketEngines.cs │ │ ├── CoresFind.cs │ │ ├── Core.cs │ │ ├── Payload.cs │ │ ├── LaunchLinks.cs │ │ ├── Info.cs │ │ ├── String_comparison_exp.cs │ │ ├── PayloadOrbitParams.cs │ │ ├── Launch.cs │ │ ├── ShipsFind.cs │ │ ├── PayloadsFind.cs │ │ ├── Rocket.cs │ │ ├── Ship.cs │ │ ├── Dragon.cs │ │ ├── Roadster.cs │ │ └── LaunchFind.cs │ ├── Generated.csproj │ ├── SuperChargersGraphContext.cs │ └── HslGraphContext.cs ├── build.cmd ├── GraphQLinq.sln.DotSettings ├── build │ ├── .editorconfig │ ├── Configuration.cs │ ├── _build.csproj │ ├── Build.cs │ └── _build.csproj.DotSettings ├── Directory.Build.props ├── appveyor.yml ├── GraphQLinq.Client │ ├── GraphQueryExecutionException.cs │ ├── GraphContext.cs │ ├── Client.csproj │ ├── ExtensionsUtils.cs │ ├── GraphQueryEnumerator.cs │ ├── GraphQuery.cs │ └── GraphQueryBuilder.cs ├── GraphQLinq.Tests │ ├── Tests.csproj │ ├── MethodIncludeQueryGenerationTests.cs │ ├── CollectionQueryTests.cs │ ├── SuperChargersTests.cs │ ├── SingleItemQueryTests.cs │ └── QueryGenerationTests.cs ├── GraphQLinq.Scaffolding │ ├── RootSchemaObject.cs │ ├── Scaffolding.csproj │ ├── ExtensionsUtils.cs │ └── Program.cs ├── build.sh ├── GraphQLinq.Demo │ ├── Demo.csproj │ └── Program.cs ├── build.ps1 └── GraphQLinq.sln ├── docs ├── Images │ ├── Icon.png │ └── Scaffolding.gif └── README-NuGet.md ├── LICENSE.md ├── .github └── FUNDING.yml ├── .gitattributes ├── .gitignore └── README.md /src/global.json: -------------------------------------------------------------------------------- 1 | { 2 | "sdk": { 3 | "version": "6.0.201" 4 | } 5 | } -------------------------------------------------------------------------------- /docs/Images/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dibble-james/GraphQLinq/master/docs/Images/Icon.png -------------------------------------------------------------------------------- /src/.nuke/parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./build.schema.json", 3 | "Solution": "GraphQLinq.sln" 4 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SuperChargers/Node.cs: -------------------------------------------------------------------------------- 1 | public interface Node 2 | { 3 | string id { get; set; } 4 | } -------------------------------------------------------------------------------- /docs/Images/Scaffolding.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dibble-james/GraphQLinq/master/docs/Images/Scaffolding.gif -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SuperChargers/Region.cs: -------------------------------------------------------------------------------- 1 | public enum Region 2 | { 3 | NORTH_AMERICA, 4 | EUROPE, 5 | ASIA_PACIFIC 6 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/Node.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public interface Node 4 | { 5 | string id { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Users_constraint.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | public enum Users_constraint 4 | { 5 | users_pkey 6 | } 7 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Conflict_action.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | public enum Conflict_action 4 | { 5 | ignore, 6 | update 7 | } 8 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SuperChargers/Email.cs: -------------------------------------------------------------------------------- 1 | public partial class Email 2 | { 3 | public string email { get; set; } 4 | public string label { get; set; } 5 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SuperChargers/Phone.cs: -------------------------------------------------------------------------------- 1 | public partial class Phone 2 | { 3 | public string number { get; set; } 4 | public string label { get; set; } 5 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/debugOutput.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public partial class debugOutput 4 | { 5 | public long totalTime { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/LocationType.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public enum LocationType 4 | { 5 | STOP, 6 | STATION, 7 | ENTRANCE 8 | } 9 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/BikesAllowed.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public enum BikesAllowed 4 | { 5 | NO_INFORMATION, 6 | ALLOWED, 7 | NOT_ALLOWED 8 | } 9 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SuperChargers/LocationType.cs: -------------------------------------------------------------------------------- 1 | public enum LocationType 2 | { 3 | SUPERCHARGER, 4 | STANDARD_CHARGER, 5 | DESTINATION_CHARGER, 6 | STORE, 7 | SERVICE 8 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/WheelchairBoarding.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public enum WheelchairBoarding 4 | { 5 | NO_INFORMATION, 6 | POSSIBLE, 7 | NOT_POSSIBLE 8 | } 9 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/Coordinates.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public partial class Coordinates 4 | { 5 | public float lat { get; set; } 6 | public float lon { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/LegGeometry.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public partial class LegGeometry 4 | { 5 | public int length { get; set; } 6 | public string points { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/serviceTimeRange.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public partial class serviceTimeRange 4 | { 5 | public long start { get; set; } 6 | public long end { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/TranslatedString.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public partial class TranslatedString 4 | { 5 | public string text { get; set; } 6 | public string language { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/PickupDropoffType.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public enum PickupDropoffType 4 | { 5 | SCHEDULED, 6 | NONE, 7 | CALL_AGENCY, 8 | COORDINATE_WITH_DRIVER 9 | } 10 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/PlaceInterface.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public interface PlaceInterface 4 | { 5 | string id { get; set; } 6 | float lat { get; set; } 7 | float lon { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/RealtimeState.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public enum RealtimeState 4 | { 5 | SCHEDULED, 6 | UPDATED, 7 | CANCELED, 8 | ADDED, 9 | MODIFIED 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/VertexType.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public enum VertexType 4 | { 5 | NORMAL, 6 | TRANSIT, 7 | BIKEPARK, 8 | BIKESHARE, 9 | PARKANDRIDE 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/stopAtDistanceEdge.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public partial class stopAtDistanceEdge 4 | { 5 | public stopAtDistance node { get; set; } 6 | public string cursor { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/placeAtDistanceEdge.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public partial class placeAtDistanceEdge 4 | { 5 | public placeAtDistance node { get; set; } 6 | public string cursor { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /src/build.cmd: -------------------------------------------------------------------------------- 1 | :; set -eo pipefail 2 | :; SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) 3 | :; ${SCRIPT_DIR}/build.sh "$@" 4 | :; exit $? 5 | 6 | @ECHO OFF 7 | powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0build.ps1" %* 8 | -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Result.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Result 7 | { 8 | public int? TotalCount { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Users_select_column.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | public enum Users_select_column 4 | { 5 | id, 6 | name, 7 | rocket, 8 | timestamp, 9 | twitter 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Users_update_column.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | public enum Users_update_column 4 | { 5 | id, 6 | name, 7 | rocket, 8 | timestamp, 9 | twitter 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/FilterPlaceType.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public enum FilterPlaceType 4 | { 5 | STOP, 6 | DEPARTURE_ROW, 7 | BICYCLE_RENT, 8 | BIKE_PARK, 9 | CAR_PARK 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/OptimizeType.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public enum OptimizeType 4 | { 5 | QUICK, 6 | SAFE, 7 | FLAT, 8 | GREENWAYS, 9 | TRIANGLE, 10 | TRANSFERS 11 | } 12 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/stopAtDistance.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public partial class stopAtDistance : Node 4 | { 5 | public string id { get; set; } 6 | public Stop stop { get; set; } 7 | public int distance { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/LaunchTelemetry.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class LaunchTelemetry 7 | { 8 | public string Flight_club { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Mass.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Mass 7 | { 8 | public int? Kg { get; set; } 9 | public int? Lb { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Order_by.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | public enum Order_by 4 | { 5 | asc, 6 | asc_nulls_first, 7 | asc_nulls_last, 8 | desc, 9 | desc_nulls_first, 10 | desc_nulls_last 11 | } 12 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/placeAtDistance.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public partial class placeAtDistance : Node 4 | { 5 | public string id { get; set; } 6 | public PlaceInterface place { get; set; } 7 | public int distance { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Force.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Force 7 | { 8 | public float? KN { get; set; } 9 | public float? Lbf { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/DragonPressurizedCapsule.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class DragonPressurizedCapsule 7 | { 8 | public Volume Payload_volume { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Distance.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Distance 7 | { 8 | public float? Feet { get; set; } 9 | public float? Meters { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/StoptimesInPattern.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | using System.Collections.Generic; 4 | 5 | public partial class StoptimesInPattern 6 | { 7 | public Pattern pattern { get; set; } 8 | public List stoptimes { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/CoreMission.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class CoreMission 7 | { 8 | public string Name { get; set; } 9 | public int? Flight { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/LaunchRocketFirstStage.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class LaunchRocketFirstStage 7 | { 8 | public List Cores { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/ShipMission.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class ShipMission 7 | { 8 | public string Flight { get; set; } 9 | public string Name { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Volume.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Volume 7 | { 8 | public int? Cubic_feet { get; set; } 9 | public int? Cubic_meters { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/CapsuleMission.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class CapsuleMission 7 | { 8 | public int? Flight { get; set; } 9 | public string Name { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/ShipsResult.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class ShipsResult 7 | { 8 | public Result Result { get; set; } 9 | public List Data { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/MissionResult.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class MissionResult 7 | { 8 | public Result Result { get; set; } 9 | public List Data { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/RocketsResult.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class RocketsResult 7 | { 8 | public Result Result { get; set; } 9 | public List Data { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/ShipLocation.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class ShipLocation 7 | { 8 | public float? Latitude { get; set; } 9 | public float? Longitude { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/HistoriesResult.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class HistoriesResult 7 | { 8 | public Result Result { get; set; } 9 | public List Data { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/RocketLandingLegs.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class RocketLandingLegs 7 | { 8 | public int? Number { get; set; } 9 | public string Material { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/stopAtDistanceConnection.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | using System.Collections.Generic; 4 | 5 | public partial class stopAtDistanceConnection 6 | { 7 | public List edges { get; set; } 8 | public PageInfo pageInfo { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/DragonTrunk.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class DragonTrunk 7 | { 8 | public DragonTrunkCargo Cargo { get; set; } 9 | public Volume Trunk_volume { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/LaunchesPastResult.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class LaunchesPastResult 7 | { 8 | public Result Result { get; set; } 9 | public List Data { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/placeAtDistanceConnection.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | using System.Collections.Generic; 4 | 5 | public partial class placeAtDistanceConnection 6 | { 7 | public List edges { get; set; } 8 | public PageInfo pageInfo { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/DragonTrunkCargo.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class DragonTrunkCargo 7 | { 8 | public int? Solar_array { get; set; } 9 | public bool? Unpressurized_cargo { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/PageInfo.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public partial class PageInfo 4 | { 5 | public bool hasNextPage { get; set; } 6 | public bool hasPreviousPage { get; set; } 7 | public string startCursor { get; set; } 8 | public string endCursor { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/LaunchRocketSecondStage.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class LaunchRocketSecondStage 7 | { 8 | public int? Block { get; set; } 9 | public List Payloads { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Users_aggregate.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Users_aggregate 7 | { 8 | public Users_aggregate_fields Aggregate { get; set; } 9 | public List Nodes { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Link.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Link 7 | { 8 | public string Article { get; set; } 9 | public string Reddit { get; set; } 10 | public string Wikipedia { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Users_mutation_response.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Users_mutation_response 7 | { 8 | public int Affected_rows { get; set; } 9 | public List Returning { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Address.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class AddressType 7 | { 8 | public string Address { get; set; } 9 | public string City { get; set; } 10 | public string State { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Users_on_conflict.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Users_on_conflict 7 | { 8 | public Users_constraint Constraint { get; set; } 9 | public List Update_columns { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/LaunchSite.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class LaunchSite 7 | { 8 | public string Site_id { get; set; } 9 | public string Site_name_long { get; set; } 10 | public string Site_name { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Users_obj_rel_insert_input.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Users_obj_rel_insert_input 7 | { 8 | public Users_insert_input Data { get; set; } 9 | public Users_on_conflict On_conflict { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/RocketSecondStagePayloadCompositeFairing.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class RocketSecondStagePayloadCompositeFairing 7 | { 8 | public Distance Height { get; set; } 9 | public Distance Diameter { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Users_arr_rel_insert_input.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Users_arr_rel_insert_input 7 | { 8 | public List Data { get; set; } 9 | public Users_on_conflict On_conflict { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/fare.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | using System.Collections.Generic; 4 | 5 | public partial class fare 6 | { 7 | public string type { get; set; } 8 | public string currency { get; set; } 9 | public int cents { get; set; } 10 | public List components { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/fareComponent.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | using System.Collections.Generic; 4 | 5 | public partial class fareComponent 6 | { 7 | public string fareId { get; set; } 8 | public string currency { get; set; } 9 | public int cents { get; set; } 10 | public List routes { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/RocketSecondStagePayloads.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class RocketSecondStagePayloads 7 | { 8 | public string Option_1 { get; set; } 9 | public RocketSecondStagePayloadCompositeFairing Composite_fairing { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Users_aggregate_fields.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Users_aggregate_fields 7 | { 8 | public int? Count { get; set; } 9 | public Users_max_fields Max { get; set; } 10 | public Users_min_fields Min { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Location.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Location 7 | { 8 | public float? Latitude { get; set; } 9 | public float? Longitude { get; set; } 10 | public string Name { get; set; } 11 | public string Region { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/RocketPayloadWeight.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class RocketPayloadWeight 7 | { 8 | public string Id { get; set; } 9 | public int? Kg { get; set; } 10 | public int? Lb { get; set; } 11 | public string Name { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Users_aggregate_order_by.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Users_aggregate_order_by 7 | { 8 | public Order_by Count { get; set; } 9 | public Users_max_order_by Max { get; set; } 10 | public Users_min_order_by Min { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/Mode.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public enum Mode 4 | { 5 | AIRPLANE, 6 | BICYCLE, 7 | BUS, 8 | CABLE_CAR, 9 | CAR, 10 | FERRY, 11 | FUNICULAR, 12 | GONDOLA, 13 | LEG_SWITCH, 14 | RAIL, 15 | SUBWAY, 16 | TRAM, 17 | TRANSIT, 18 | WALK 19 | } 20 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/HistoryFind.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class HistoryFind 7 | { 8 | public DateTime? End { get; set; } 9 | public int? Flight_number { get; set; } 10 | public string Id { get; set; } 11 | public DateTime? Start { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/InfoLinks.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class InfoLinks 7 | { 8 | public string Elon_twitter { get; set; } 9 | public string Flickr { get; set; } 10 | public string Twitter { get; set; } 11 | public string Website { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/MissionsFind.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class MissionsFind 7 | { 8 | public string Id { get; set; } 9 | public string Manufacturer { get; set; } 10 | public string Name { get; set; } 11 | public string Payload_id { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Users_max_fields.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Users_max_fields 7 | { 8 | public string Name { get; set; } 9 | public string Rocket { get; set; } 10 | public DateTimeOffset? Timestamp { get; set; } 11 | public string Twitter { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Users_min_fields.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Users_min_fields 7 | { 8 | public string Name { get; set; } 9 | public string Rocket { get; set; } 10 | public DateTimeOffset? Timestamp { get; set; } 11 | public string Twitter { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/DragonHeatShield.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class DragonHeatShield 7 | { 8 | public string Dev_partner { get; set; } 9 | public string Material { get; set; } 10 | public float? Size_meters { get; set; } 11 | public int? Temp_degrees { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/LaunchRocketFairings.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class LaunchRocketFairings 7 | { 8 | public bool? Recovered { get; set; } 9 | public bool? Recovery_attempt { get; set; } 10 | public bool? Reused { get; set; } 11 | public string Ship { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Users_max_order_by.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Users_max_order_by 7 | { 8 | public Order_by Name { get; set; } 9 | public Order_by Rocket { get; set; } 10 | public Order_by Timestamp { get; set; } 11 | public Order_by Twitter { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Users_min_order_by.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Users_min_order_by 7 | { 8 | public Order_by Name { get; set; } 9 | public Order_by Rocket { get; set; } 10 | public Order_by Timestamp { get; set; } 11 | public Order_by Twitter { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Users.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Users 7 | { 8 | public Guid Id { get; set; } 9 | public string Name { get; set; } 10 | public string Rocket { get; set; } 11 | public DateTimeOffset Timestamp { get; set; } 12 | public string Twitter { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /src/GraphQLinq.sln.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | QL -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/Cluster.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | using System.Collections.Generic; 4 | 5 | public partial class Cluster : Node 6 | { 7 | public string id { get; set; } 8 | public string gtfsId { get; set; } 9 | public string name { get; set; } 10 | public float lat { get; set; } 11 | public float lon { get; set; } 12 | public List stops { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Users_order_by.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Users_order_by 7 | { 8 | public Order_by Id { get; set; } 9 | public Order_by Name { get; set; } 10 | public Order_by Rocket { get; set; } 11 | public Order_by Timestamp { get; set; } 12 | public Order_by Twitter { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Users_set_input.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Users_set_input 7 | { 8 | public Guid? Id { get; set; } 9 | public string Name { get; set; } 10 | public string Rocket { get; set; } 11 | public DateTimeOffset? Timestamp { get; set; } 12 | public string Twitter { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Users_insert_input.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Users_insert_input 7 | { 8 | public Guid? Id { get; set; } 9 | public string Name { get; set; } 10 | public string Rocket { get; set; } 11 | public DateTimeOffset? Timestamp { get; set; } 12 | public string Twitter { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/BikePark.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public partial class BikePark : Node, PlaceInterface 4 | { 5 | public string id { get; set; } 6 | public string bikeParkId { get; set; } 7 | public string name { get; set; } 8 | public int spacesAvailable { get; set; } 9 | public bool realtime { get; set; } 10 | public float lon { get; set; } 11 | public float lat { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/DepartureRow.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | using System.Collections.Generic; 4 | 5 | public partial class DepartureRow : Node, PlaceInterface 6 | { 7 | public string id { get; set; } 8 | public Stop stop { get; set; } 9 | public float lat { get; set; } 10 | public float lon { get; set; } 11 | public Pattern pattern { get; set; } 12 | public List stoptimes { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/DragonThrust.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class DragonThrust 7 | { 8 | public int? Amount { get; set; } 9 | public string Fuel_1 { get; set; } 10 | public string Fuel_2 { get; set; } 11 | public int? Pods { get; set; } 12 | public Force Thrust { get; set; } 13 | public string Type { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/RocketSecondStage.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class RocketSecondStage 7 | { 8 | public int? Burn_time_sec { get; set; } 9 | public int? Engines { get; set; } 10 | public float? Fuel_amount_tons { get; set; } 11 | public RocketSecondStagePayloads Payloads { get; set; } 12 | public Force Thrust { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/QueryExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public static class QueryExtensions 7 | { 8 | public static int Count(this Users_aggregate_fields users_aggregate_fields, List columns, bool distinct) 9 | { 10 | throw new NotImplementedException("This method is not implemented. It exists solely for query purposes."); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/CarPark.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public partial class CarPark : Node, PlaceInterface 4 | { 5 | public string id { get; set; } 6 | public string carParkId { get; set; } 7 | public string name { get; set; } 8 | public int maxCapacity { get; set; } 9 | public int spacesAvailable { get; set; } 10 | public bool realtime { get; set; } 11 | public float lon { get; set; } 12 | public float lat { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/Place.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public partial class Place 4 | { 5 | public string name { get; set; } 6 | public VertexType vertexType { get; set; } 7 | public float lat { get; set; } 8 | public float lon { get; set; } 9 | public Stop stop { get; set; } 10 | public BikeRentalStation bikeRentalStation { get; set; } 11 | public BikePark bikePark { get; set; } 12 | public CarPark carPark { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/RocketFirstStage.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class RocketFirstStage 7 | { 8 | public int? Burn_time_sec { get; set; } 9 | public int? Engines { get; set; } 10 | public float? Fuel_amount_tons { get; set; } 11 | public bool? Reusable { get; set; } 12 | public Force Thrust_sea_level { get; set; } 13 | public Force Thrust_vacuum { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/Plan.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | using System.Collections.Generic; 4 | 5 | public partial class Plan 6 | { 7 | public long date { get; set; } 8 | public Place from { get; set; } 9 | public Place to { get; set; } 10 | public List itineraries { get; set; } 11 | public List messageEnums { get; set; } 12 | public List messageStrings { get; set; } 13 | public debugOutput debugOutput { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/History.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class History 7 | { 8 | public string Details { get; set; } 9 | public DateTime? Event_date_unix { get; set; } 10 | public DateTime? Event_date_utc { get; set; } 11 | public string Id { get; set; } 12 | public Link Links { get; set; } 13 | public string Title { get; set; } 14 | public Launch Flight { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/CapsulesFind.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class CapsulesFind 7 | { 8 | public string Id { get; set; } 9 | public int? Landings { get; set; } 10 | public string Mission { get; set; } 11 | public DateTime? Original_launch { get; set; } 12 | public int? Reuse_count { get; set; } 13 | public string Status { get; set; } 14 | public string Type { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/LaunchRocket.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class LaunchRocket 7 | { 8 | public LaunchRocketFairings Fairings { get; set; } 9 | public LaunchRocketFirstStage First_stage { get; set; } 10 | public string Rocket_name { get; set; } 11 | public string Rocket_type { get; set; } 12 | public Rocket Rocket { get; set; } 13 | public LaunchRocketSecondStage Second_stage { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/Itinerary.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | using System.Collections.Generic; 4 | 5 | public partial class Itinerary 6 | { 7 | public long startTime { get; set; } 8 | public long endTime { get; set; } 9 | public long duration { get; set; } 10 | public long waitingTime { get; set; } 11 | public long walkTime { get; set; } 12 | public float walkDistance { get; set; } 13 | public List legs { get; set; } 14 | public List fares { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /src/build/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.cs] 2 | dotnet_style_qualification_for_field = false:warning 3 | dotnet_style_qualification_for_property = false:warning 4 | dotnet_style_qualification_for_method = false:warning 5 | dotnet_style_qualification_for_event = false:warning 6 | dotnet_style_require_accessibility_modifiers = never:warning 7 | 8 | csharp_style_expression_bodied_methods = true:silent 9 | csharp_style_expression_bodied_properties = true:warning 10 | csharp_style_expression_bodied_indexers = true:warning 11 | csharp_style_expression_bodied_accessors = true:warning 12 | -------------------------------------------------------------------------------- /src/build/Configuration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Linq; 4 | using Nuke.Common.Tooling; 5 | 6 | [TypeConverter(typeof(TypeConverter))] 7 | public class Configuration : Enumeration 8 | { 9 | public static Configuration Debug = new Configuration { Value = nameof(Debug) }; 10 | public static Configuration Release = new Configuration { Value = nameof(Release) }; 11 | 12 | public static implicit operator string(Configuration configuration) 13 | { 14 | return configuration.Value; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Capsule.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Capsule 7 | { 8 | public string Id { get; set; } 9 | public int? Landings { get; set; } 10 | public List Missions { get; set; } 11 | public DateTime? Original_launch { get; set; } 12 | public int? Reuse_count { get; set; } 13 | public string Status { get; set; } 14 | public string Type { get; set; } 15 | public Dragon Dragon { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Mission.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Mission 7 | { 8 | public string Description { get; set; } 9 | public string Id { get; set; } 10 | public List Manufacturers { get; set; } 11 | public string Name { get; set; } 12 | public string Twitter { get; set; } 13 | public string Website { get; set; } 14 | public string Wikipedia { get; set; } 15 | public List Payloads { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /src/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(SolutionName).$(MSBuildProjectName) 4 | $(AssemblyName) 5 | 6 | 7 | 8 | 0.1.0 9 | 0.1.0.0 10 | 0.1.0.0 11 | Giorgi Dalakishvili 12 | Copyright (c) 2017 - 2021 Giorgi Dalakishvili 13 | 14 | -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Uuid_comparison_exp.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Uuid_comparison_exp 7 | { 8 | public Guid? _eq { get; set; } 9 | public Guid? _gt { get; set; } 10 | public Guid? _gte { get; set; } 11 | public List _in { get; set; } 12 | public bool? _is_null { get; set; } 13 | public Guid? _lt { get; set; } 14 | public Guid? _lte { get; set; } 15 | public Guid? _neq { get; set; } 16 | public List _nin { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /src/build/_build.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6 6 | 7 | CS0649;CS0169 8 | .. 9 | ..\src 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017-2021 Giorgi Dalakishvili. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/Agency.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | using System.Collections.Generic; 4 | 5 | public partial class Agency : Node 6 | { 7 | public string id { get; set; } 8 | public string gtfsId { get; set; } 9 | public string name { get; set; } 10 | public string url { get; set; } 11 | public string timezone { get; set; } 12 | public string lang { get; set; } 13 | public string phone { get; set; } 14 | public string fareUrl { get; set; } 15 | public List routes { get; set; } 16 | public List alerts { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SuperChargers/Country.cs: -------------------------------------------------------------------------------- 1 | public enum Country 2 | { 3 | LUXEMBOURG, 4 | FRANCE, 5 | GERMANY, 6 | DENMARK, 7 | FINLAND, 8 | MEXICO, 9 | TAIWAN, 10 | UNITED_KINGDOM, 11 | UNITED_STATES, 12 | ANDORRA, 13 | BELGIUM, 14 | CZECH_REPUBLIC, 15 | SWEDEN, 16 | POLAND, 17 | SLOVAKIA, 18 | AUSTRIA, 19 | CHINA, 20 | SPAIN, 21 | SWITZERLAND, 22 | CANADA, 23 | CROATIA, 24 | SLOVENIA, 25 | LIECHTENSTEIN, 26 | NORWAY, 27 | MACAU, 28 | NETHERLANDS, 29 | AUSTRALIA, 30 | JAPAN, 31 | SERBIA, 32 | HONG_KONG, 33 | ITALY 34 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/Generated.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net5.0 4 | Library 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Landpad.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Landpad 7 | { 8 | public string Attempted_landings { get; set; } 9 | public string Details { get; set; } 10 | public string Full_name { get; set; } 11 | public string Id { get; set; } 12 | public string Landing_type { get; set; } 13 | public Location Location { get; set; } 14 | public string Status { get; set; } 15 | public string Successful_landings { get; set; } 16 | public string Wikipedia { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Launchpad.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Launchpad 7 | { 8 | public int? Attempted_launches { get; set; } 9 | public string Details { get; set; } 10 | public string Id { get; set; } 11 | public Location Location { get; set; } 12 | public string Name { get; set; } 13 | public string Status { get; set; } 14 | public int? Successful_launches { get; set; } 15 | public List Vehicles_launched { get; set; } 16 | public string Wikipedia { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Users_bool_exp.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Users_bool_exp 7 | { 8 | public List _and { get; set; } 9 | public Users_bool_exp _not { get; set; } 10 | public List _or { get; set; } 11 | public Uuid_comparison_exp Id { get; set; } 12 | public String_comparison_exp Name { get; set; } 13 | public String_comparison_exp Rocket { get; set; } 14 | public Timestamptz_comparison_exp Timestamp { get; set; } 15 | public String_comparison_exp Twitter { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/BikeRentalStation.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | using System.Collections.Generic; 4 | 5 | public partial class BikeRentalStation : Node, PlaceInterface 6 | { 7 | public string id { get; set; } 8 | public string stationId { get; set; } 9 | public string name { get; set; } 10 | public int bikesAvailable { get; set; } 11 | public int spacesAvailable { get; set; } 12 | public bool realtime { get; set; } 13 | public bool allowDropoff { get; set; } 14 | public List networks { get; set; } 15 | public float lon { get; set; } 16 | public float lat { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/LaunchRocketFirstStageCore.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class LaunchRocketFirstStageCore 7 | { 8 | public int? Block { get; set; } 9 | public Core Core { get; set; } 10 | public int? Flight { get; set; } 11 | public bool? Gridfins { get; set; } 12 | public bool? Land_success { get; set; } 13 | public bool? Landing_intent { get; set; } 14 | public string Landing_type { get; set; } 15 | public string Landing_vehicle { get; set; } 16 | public bool? Legs { get; set; } 17 | public bool? Reused { get; set; } 18 | } 19 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Timestamptz_comparison_exp.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Timestamptz_comparison_exp 7 | { 8 | public DateTimeOffset? _eq { get; set; } 9 | public DateTimeOffset? _gt { get; set; } 10 | public DateTimeOffset? _gte { get; set; } 11 | public List _in { get; set; } 12 | public bool? _is_null { get; set; } 13 | public DateTimeOffset? _lt { get; set; } 14 | public DateTimeOffset? _lte { get; set; } 15 | public DateTimeOffset? _neq { get; set; } 16 | public List _nin { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/RocketEngines.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class RocketEngines 7 | { 8 | public int? Number { get; set; } 9 | public string Type { get; set; } 10 | public string Version { get; set; } 11 | public string Layout { get; set; } 12 | public string Engine_loss_max { get; set; } 13 | public string Propellant_1 { get; set; } 14 | public string Propellant_2 { get; set; } 15 | public Force Thrust_sea_level { get; set; } 16 | public Force Thrust_vacuum { get; set; } 17 | public float? Thrust_to_weight { get; set; } 18 | } 19 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/CoresFind.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class CoresFind 7 | { 8 | public int? Asds_attempts { get; set; } 9 | public int? Asds_landings { get; set; } 10 | public int? Block { get; set; } 11 | public string Id { get; set; } 12 | public string Missions { get; set; } 13 | public DateTime? Original_launch { get; set; } 14 | public int? Reuse_count { get; set; } 15 | public int? Rtls_attempts { get; set; } 16 | public int? Rtls_landings { get; set; } 17 | public string Status { get; set; } 18 | public bool? Water_landing { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Core.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Core 7 | { 8 | public int? Asds_attempts { get; set; } 9 | public int? Asds_landings { get; set; } 10 | public int? Block { get; set; } 11 | public string Id { get; set; } 12 | public List Missions { get; set; } 13 | public DateTime? Original_launch { get; set; } 14 | public int? Reuse_count { get; set; } 15 | public int? Rtls_attempts { get; set; } 16 | public int? Rtls_landings { get; set; } 17 | public string Status { get; set; } 18 | public bool? Water_landing { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/Pattern.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | using System.Collections.Generic; 4 | 5 | public partial class Pattern : Node 6 | { 7 | public string id { get; set; } 8 | public Route route { get; set; } 9 | public int directionId { get; set; } 10 | public string name { get; set; } 11 | public string code { get; set; } 12 | public string headsign { get; set; } 13 | public List trips { get; set; } 14 | public List tripsForDate { get; set; } 15 | public List stops { get; set; } 16 | public List geometry { get; set; } 17 | public string semanticHash { get; set; } 18 | public List alerts { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Payload.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Payload 7 | { 8 | public List Customers { get; set; } 9 | public string Id { get; set; } 10 | public string Manufacturer { get; set; } 11 | public string Nationality { get; set; } 12 | public List Norad_id { get; set; } 13 | public PayloadOrbitParams Orbit_params { get; set; } 14 | public string Orbit { get; set; } 15 | public float? Payload_mass_kg { get; set; } 16 | public float? Payload_mass_lbs { get; set; } 17 | public string Payload_type { get; set; } 18 | public bool? Reused { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: Giorgi 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: ['https://www.buymeacoffee.com/giorgidev'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/LaunchLinks.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class LaunchLinks 7 | { 8 | public string Article_link { get; set; } 9 | public List Flickr_images { get; set; } 10 | public string Mission_patch_small { get; set; } 11 | public string Mission_patch { get; set; } 12 | public string Presskit { get; set; } 13 | public string Reddit_campaign { get; set; } 14 | public string Reddit_launch { get; set; } 15 | public string Reddit_media { get; set; } 16 | public string Reddit_recovery { get; set; } 17 | public string Video_link { get; set; } 18 | public string Wikipedia { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /src/appveyor.yml: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # 3 | # 4 | # This code was generated. 5 | # 6 | # - To turn off auto-generation set: 7 | # 8 | # [AppVeyor (AutoGenerate = false)] 9 | # 10 | # - To trigger manual generation invoke: 11 | # 12 | # nuke --generate-configuration AppVeyor --host AppVeyor 13 | # 14 | # 15 | # ------------------------------------------------------------------------------ 16 | 17 | image: 18 | - Visual Studio 2019 19 | 20 | before_build: 21 | 22 | - cmd: cd src 23 | 24 | 25 | build_script: 26 | - cmd: .\build.cmd Test 27 | - sh: ./build.cmd Test 28 | 29 | environment: 30 | COVERALLS_REPO_TOKEN: 31 | secure: 0wXxQdMQF5yHgpUe3heAG5zY2YYNBZYEF9FmgqoQi6b6IC0JibAA+idcnOkwTeEg 32 | -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/Alert.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | using System.Collections.Generic; 4 | 5 | public partial class Alert : Node 6 | { 7 | public string id { get; set; } 8 | public Agency agency { get; set; } 9 | public Route route { get; set; } 10 | public Trip trip { get; set; } 11 | public Stop stop { get; set; } 12 | public List patterns { get; set; } 13 | public string alertHeaderText { get; set; } 14 | public List alertHeaderTextTranslations { get; set; } 15 | public string alertDescriptionText { get; set; } 16 | public List alertDescriptionTextTranslations { get; set; } 17 | public string alertUrl { get; set; } 18 | public long effectiveStartDate { get; set; } 19 | public long effectiveEndDate { get; set; } 20 | } 21 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/Route.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | using System.Collections.Generic; 4 | 5 | public partial class Route : Node 6 | { 7 | public string id { get; set; } 8 | public string gtfsId { get; set; } 9 | public Agency agency { get; set; } 10 | public string shortName { get; set; } 11 | public string longName { get; set; } 12 | public string mode { get; set; } 13 | public string desc { get; set; } 14 | public string url { get; set; } 15 | public string color { get; set; } 16 | public string textColor { get; set; } 17 | public BikesAllowed bikesAllowed { get; set; } 18 | public List patterns { get; set; } 19 | public List stops { get; set; } 20 | public List trips { get; set; } 21 | public List alerts { get; set; } 22 | } 23 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/Stoptime.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | public partial class Stoptime 4 | { 5 | public Stop stop { get; set; } 6 | public int scheduledArrival { get; set; } 7 | public int realtimeArrival { get; set; } 8 | public int arrivalDelay { get; set; } 9 | public int scheduledDeparture { get; set; } 10 | public int realtimeDeparture { get; set; } 11 | public int departureDelay { get; set; } 12 | public bool timepoint { get; set; } 13 | public bool realtime { get; set; } 14 | public RealtimeState realtimeState { get; set; } 15 | public PickupDropoffType pickupType { get; set; } 16 | public PickupDropoffType dropoffType { get; set; } 17 | public long serviceDay { get; set; } 18 | public Trip trip { get; set; } 19 | public string headsign { get; set; } 20 | } 21 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Info.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Info 7 | { 8 | public string Ceo { get; set; } 9 | public string Coo { get; set; } 10 | public string Cto_propulsion { get; set; } 11 | public string Cto { get; set; } 12 | public int? Employees { get; set; } 13 | public int? Founded { get; set; } 14 | public string Founder { get; set; } 15 | public AddressType Headquarters { get; set; } 16 | public int? Launch_sites { get; set; } 17 | public InfoLinks Links { get; set; } 18 | public string Name { get; set; } 19 | public string Summary { get; set; } 20 | public int? Test_sites { get; set; } 21 | public float? Valuation { get; set; } 22 | public int? Vehicles { get; set; } 23 | } 24 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/String_comparison_exp.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class String_comparison_exp 7 | { 8 | public string _eq { get; set; } 9 | public string _gt { get; set; } 10 | public string _gte { get; set; } 11 | public string _ilike { get; set; } 12 | public List _in { get; set; } 13 | public bool? _is_null { get; set; } 14 | public string _like { get; set; } 15 | public string _lt { get; set; } 16 | public string _lte { get; set; } 17 | public string _neq { get; set; } 18 | public string _nilike { get; set; } 19 | public List _nin { get; set; } 20 | public string _nlike { get; set; } 21 | public string _nsimilar { get; set; } 22 | public string _similar { get; set; } 23 | } 24 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/Leg.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | using System.Collections.Generic; 4 | 5 | public partial class Leg 6 | { 7 | public long startTime { get; set; } 8 | public long endTime { get; set; } 9 | public Mode mode { get; set; } 10 | public float duration { get; set; } 11 | public LegGeometry legGeometry { get; set; } 12 | public Agency agency { get; set; } 13 | public bool realTime { get; set; } 14 | public float distance { get; set; } 15 | public bool transitLeg { get; set; } 16 | public bool rentedBike { get; set; } 17 | public Place from { get; set; } 18 | public Place to { get; set; } 19 | public Route route { get; set; } 20 | public Trip trip { get; set; } 21 | public List intermediateStops { get; set; } 22 | public bool intermediatePlace { get; set; } 23 | } 24 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/PayloadOrbitParams.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class PayloadOrbitParams 7 | { 8 | public float? Apoapsis_km { get; set; } 9 | public float? Arg_of_pericenter { get; set; } 10 | public float? Eccentricity { get; set; } 11 | public DateTime? Epoch { get; set; } 12 | public float? Inclination_deg { get; set; } 13 | public float? Lifespan_years { get; set; } 14 | public float? Longitude { get; set; } 15 | public float? Mean_anomaly { get; set; } 16 | public float? Mean_motion { get; set; } 17 | public float? Periapsis_km { get; set; } 18 | public float? Period_min { get; set; } 19 | public float? Raan { get; set; } 20 | public string Reference_system { get; set; } 21 | public string Regime { get; set; } 22 | public float? Semi_major_axis_km { get; set; } 23 | } 24 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Client/GraphQueryExecutionException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace GraphQLinq 5 | { 6 | public class GraphQueryExecutionException : Exception 7 | { 8 | public GraphQueryExecutionException(IEnumerable errors, string query) 9 | : base($"One or more errors occured during query execution. Check {nameof(Errors)} property for details") 10 | { 11 | Errors = errors; 12 | GraphQLQuery = query; 13 | } 14 | 15 | public string GraphQLQuery { get; private set; } 16 | public IEnumerable Errors { get; private set; } 17 | } 18 | 19 | public class GraphQueryError 20 | { 21 | public string Message { get; set; } 22 | public ErrorLocation[] Locations { get; set; } 23 | } 24 | 25 | public class ErrorLocation 26 | { 27 | public int Line { get; set; } 28 | public int Column { get; set; } 29 | } 30 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Tests/Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net6 4 | false 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | all 16 | runtime; build; native; contentfiles; analyzers; buildtransitive 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/Trip.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | using System.Collections.Generic; 4 | 5 | public partial class Trip : Node 6 | { 7 | public string id { get; set; } 8 | public string gtfsId { get; set; } 9 | public Route route { get; set; } 10 | public string serviceId { get; set; } 11 | public List activeDates { get; set; } 12 | public string tripShortName { get; set; } 13 | public string tripHeadsign { get; set; } 14 | public string routeShortName { get; set; } 15 | public string directionId { get; set; } 16 | public string blockId { get; set; } 17 | public string shapeId { get; set; } 18 | public WheelchairBoarding wheelchairAccessible { get; set; } 19 | public BikesAllowed bikesAllowed { get; set; } 20 | public Pattern pattern { get; set; } 21 | public List stops { get; set; } 22 | public List semanticHash { get; set; } 23 | public List stoptimes { get; set; } 24 | public List stoptimesForDate { get; set; } 25 | public List> geometry { get; set; } 26 | public List alerts { get; set; } 27 | } 28 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Launch.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Launch 7 | { 8 | public string Details { get; set; } 9 | public string Id { get; set; } 10 | public bool? Is_tentative { get; set; } 11 | public DateTime? Launch_date_local { get; set; } 12 | public DateTime? Launch_date_unix { get; set; } 13 | public DateTime? Launch_date_utc { get; set; } 14 | public LaunchSite Launch_site { get; set; } 15 | public bool? Launch_success { get; set; } 16 | public string Launch_year { get; set; } 17 | public LaunchLinks Links { get; set; } 18 | public List Mission_id { get; set; } 19 | public string Mission_name { get; set; } 20 | public LaunchRocket Rocket { get; set; } 21 | public DateTime? Static_fire_date_unix { get; set; } 22 | public DateTime? Static_fire_date_utc { get; set; } 23 | public LaunchTelemetry Telemetry { get; set; } 24 | public string Tentative_max_precision { get; set; } 25 | public bool? Upcoming { get; set; } 26 | public List Ships { get; set; } 27 | } 28 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/ShipsFind.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class ShipsFind 7 | { 8 | public string Id { get; set; } 9 | public string Name { get; set; } 10 | public string Model { get; set; } 11 | public string Type { get; set; } 12 | public string Role { get; set; } 13 | public bool? Active { get; set; } 14 | public int? Imo { get; set; } 15 | public int? Mmsi { get; set; } 16 | public int? Abs { get; set; } 17 | public int? Class { get; set; } 18 | public int? Weight_lbs { get; set; } 19 | public int? Weight_kg { get; set; } 20 | public int? Year_built { get; set; } 21 | public string Home_port { get; set; } 22 | public string Status { get; set; } 23 | public int? Speed_kn { get; set; } 24 | public int? Course_deg { get; set; } 25 | public float? Latitude { get; set; } 26 | public float? Longitude { get; set; } 27 | public int? Successful_landings { get; set; } 28 | public int? Attempted_landings { get; set; } 29 | public string Mission { get; set; } 30 | } 31 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/PayloadsFind.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class PayloadsFind 7 | { 8 | public float? Apoapsis_km { get; set; } 9 | public string Customer { get; set; } 10 | public float? Eccentricity { get; set; } 11 | public DateTime? Epoch { get; set; } 12 | public float? Inclination_deg { get; set; } 13 | public float? Lifespan_years { get; set; } 14 | public float? Longitude { get; set; } 15 | public string Manufacturer { get; set; } 16 | public float? Mean_motion { get; set; } 17 | public string Nationality { get; set; } 18 | public int? Norad_id { get; set; } 19 | public string Orbit { get; set; } 20 | public string Payload_id { get; set; } 21 | public string Payload_type { get; set; } 22 | public float? Periapsis_km { get; set; } 23 | public float? Period_min { get; set; } 24 | public float? Raan { get; set; } 25 | public string Reference_system { get; set; } 26 | public string Regime { get; set; } 27 | public bool? Reused { get; set; } 28 | public float? Semi_major_axis_km { get; set; } 29 | } 30 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Rocket.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Rocket 7 | { 8 | public bool? Active { get; set; } 9 | public int? Boosters { get; set; } 10 | public string Company { get; set; } 11 | public int? Cost_per_launch { get; set; } 12 | public string Country { get; set; } 13 | public string Description { get; set; } 14 | public Distance Diameter { get; set; } 15 | public RocketEngines Engines { get; set; } 16 | public DateTime? First_flight { get; set; } 17 | public RocketFirstStage First_stage { get; set; } 18 | public Distance Height { get; set; } 19 | public string Id { get; set; } 20 | public RocketLandingLegs Landing_legs { get; set; } 21 | public Mass Mass { get; set; } 22 | public string Name { get; set; } 23 | public List Payload_weights { get; set; } 24 | public RocketSecondStage Second_stage { get; set; } 25 | public int? Stages { get; set; } 26 | public int? Success_rate_pct { get; set; } 27 | public string Type { get; set; } 28 | public string Wikipedia { get; set; } 29 | } 30 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Ship.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Ship 7 | { 8 | public int? Abs { get; set; } 9 | public bool? Active { get; set; } 10 | public int? Attempted_landings { get; set; } 11 | public int? Class { get; set; } 12 | public int? Course_deg { get; set; } 13 | public string Home_port { get; set; } 14 | public string Id { get; set; } 15 | public string Image { get; set; } 16 | public int? Imo { get; set; } 17 | public List Missions { get; set; } 18 | public int? Mmsi { get; set; } 19 | public string Model { get; set; } 20 | public string Name { get; set; } 21 | public ShipLocation Position { get; set; } 22 | public List Roles { get; set; } 23 | public float? Speed_kn { get; set; } 24 | public string Status { get; set; } 25 | public int? Successful_landings { get; set; } 26 | public string Type { get; set; } 27 | public string Url { get; set; } 28 | public int? Weight_kg { get; set; } 29 | public int? Weight_lbs { get; set; } 30 | public int? Year_built { get; set; } 31 | } 32 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SuperChargersGraphContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace GraphQLinq 4 | { 5 | public class SuperChargersGraphContext : GraphContext 6 | { 7 | public SuperChargersGraphContext(string baseUrl) : base(baseUrl, "") { } 8 | public SuperChargersGraphContext(string baseUrl, string authorization) : base(baseUrl, authorization) { } 9 | 10 | public GraphCollectionQuery Locations(string before = null, string after = null, bool? openSoon = null, bool? isGallery = null, float? boundingBox = null, 11 | int? first = null, int? last = null, List type = null, Region? region = null, Country? country = null) 12 | { 13 | var parameterValues = new object[] { before, after, openSoon, isGallery, boundingBox, first, last, type, region, country }; 14 | 15 | return BuildCollectionQuery(parameterValues); 16 | } 17 | 18 | public GraphCollectionQuery Near(float latitude, float longitude, int? first = null, int? last = null, List type = null, string before = null, string after = null) 19 | { 20 | var parameterValues = new object[] { latitude, longitude, first, last, type, before, after }; 21 | 22 | return BuildCollectionQuery(parameterValues); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Dragon.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Dragon 7 | { 8 | public bool? Active { get; set; } 9 | public int? Crew_capacity { get; set; } 10 | public string Description { get; set; } 11 | public Distance Diameter { get; set; } 12 | public int? Dry_mass_kg { get; set; } 13 | public int? Dry_mass_lb { get; set; } 14 | public string First_flight { get; set; } 15 | public DragonHeatShield Heat_shield { get; set; } 16 | public Distance Height_w_trunk { get; set; } 17 | public string Id { get; set; } 18 | public Mass Launch_payload_mass { get; set; } 19 | public Volume Launch_payload_vol { get; set; } 20 | public string Name { get; set; } 21 | public int? Orbit_duration_yr { get; set; } 22 | public DragonPressurizedCapsule Pressurized_capsule { get; set; } 23 | public Mass Return_payload_mass { get; set; } 24 | public Volume Return_payload_vol { get; set; } 25 | public float? Sidewall_angle_deg { get; set; } 26 | public List Thrusters { get; set; } 27 | public DragonTrunk Trunk { get; set; } 28 | public string Type { get; set; } 29 | public string Wikipedia { get; set; } 30 | } 31 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/Roadster.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class Roadster 7 | { 8 | public float? Apoapsis_au { get; set; } 9 | public string Details { get; set; } 10 | public float? Earth_distance_km { get; set; } 11 | public float? Earth_distance_mi { get; set; } 12 | public float? Eccentricity { get; set; } 13 | public float? Epoch_jd { get; set; } 14 | public float? Inclination { get; set; } 15 | public DateTime? Launch_date_unix { get; set; } 16 | public DateTime? Launch_date_utc { get; set; } 17 | public int? Launch_mass_kg { get; set; } 18 | public int? Launch_mass_lbs { get; set; } 19 | public float? Longitude { get; set; } 20 | public float? Mars_distance_km { get; set; } 21 | public float? Mars_distance_mi { get; set; } 22 | public string Name { get; set; } 23 | public int? Norad_id { get; set; } 24 | public float? Orbit_type { get; set; } 25 | public float? Periapsis_arg { get; set; } 26 | public float? Periapsis_au { get; set; } 27 | public float? Period_days { get; set; } 28 | public float? Semi_major_axis_au { get; set; } 29 | public float? Speed_kph { get; set; } 30 | public float? Speed_mph { get; set; } 31 | public string Wikipedia { get; set; } 32 | } 33 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/Stop.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | using System.Collections.Generic; 4 | 5 | public partial class Stop : Node, PlaceInterface 6 | { 7 | public string id { get; set; } 8 | public List stopTimesForPattern { get; set; } 9 | public string gtfsId { get; set; } 10 | public string name { get; set; } 11 | public float lat { get; set; } 12 | public float lon { get; set; } 13 | public string code { get; set; } 14 | public string desc { get; set; } 15 | public string zoneId { get; set; } 16 | public string url { get; set; } 17 | public LocationType locationType { get; set; } 18 | public Stop parentStation { get; set; } 19 | public WheelchairBoarding wheelchairBoarding { get; set; } 20 | public string direction { get; set; } 21 | public string timezone { get; set; } 22 | public int vehicleType { get; set; } 23 | public string platformCode { get; set; } 24 | public Cluster cluster { get; set; } 25 | public List stops { get; set; } 26 | public List routes { get; set; } 27 | public List patterns { get; set; } 28 | public List transfers { get; set; } 29 | public List stoptimesForServiceDate { get; set; } 30 | public List stoptimesForPatterns { get; set; } 31 | public List stoptimesWithoutPatterns { get; set; } 32 | } 33 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SuperChargers/Location.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | public partial class Location : Node 4 | { 5 | public string region { get; set; } 6 | public int kioskPinY { get; set; } 7 | public int kioskZoomPinY { get; set; } 8 | public string path { get; set; } 9 | public float longitude { get; set; } 10 | public string provinceState { get; set; } 11 | public string addressLine2 { get; set; } 12 | public string address { get; set; } 13 | public string Country { get; set; } 14 | public float latitude { get; set; } 15 | public string locationId { get; set; } 16 | public List salesPhone { get; set; } 17 | public int kioskZoomPinX { get; set; } 18 | public string city { get; set; } 19 | public bool isGallery { get; set; } 20 | public string commonName { get; set; } 21 | public string destinationChargerLogo { get; set; } 22 | public string title { get; set; } 23 | public string id { get; set; } 24 | public bool openSoon { get; set; } 25 | public int nid { get; set; } 26 | public string hours { get; set; } 27 | public int kioskPinX { get; set; } 28 | public string addressNotes { get; set; } 29 | public string destinationWebsite { get; set; } 30 | public List locationType { get; set; } 31 | public string subRegion { get; set; } 32 | public string addressLine1 { get; set; } 33 | public bool salesRepresentative { get; set; } 34 | public string amentities { get; set; } 35 | public string postalCode { get; set; } 36 | public string geocode { get; set; } 37 | public List emails { get; set; } 38 | public string chargers { get; set; } 39 | public string directionsLink { get; set; } 40 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HSL/QueryType.cs: -------------------------------------------------------------------------------- 1 | namespace HSL 2 | { 3 | using System.Collections.Generic; 4 | 5 | public partial class QueryType 6 | { 7 | public Node node { get; set; } 8 | public List agencies { get; set; } 9 | public Agency agency { get; set; } 10 | public List stops { get; set; } 11 | public List stopsByBbox { get; set; } 12 | public stopAtDistanceConnection stopsByRadius { get; set; } 13 | public placeAtDistanceConnection nearest { get; set; } 14 | public DepartureRow departureRow { get; set; } 15 | public Stop stop { get; set; } 16 | public Stop station { get; set; } 17 | public List stations { get; set; } 18 | public List routes { get; set; } 19 | public Route route { get; set; } 20 | public List trips { get; set; } 21 | public Trip trip { get; set; } 22 | public Trip fuzzyTrip { get; set; } 23 | public List patterns { get; set; } 24 | public Pattern pattern { get; set; } 25 | public List clusters { get; set; } 26 | public Cluster cluster { get; set; } 27 | public List alerts { get; set; } 28 | public serviceTimeRange serviceTimeRange { get; set; } 29 | public List bikeRentalStations { get; set; } 30 | public BikeRentalStation bikeRentalStation { get; set; } 31 | public List bikeParks { get; set; } 32 | public BikePark bikePark { get; set; } 33 | public List carParks { get; set; } 34 | public CarPark carPark { get; set; } 35 | public QueryType viewer { get; set; } 36 | public Plan plan { get; set; } 37 | } 38 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Client/GraphContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Reflection; 4 | using System.Runtime.CompilerServices; 5 | using Newtonsoft.Json.Serialization; 6 | 7 | namespace GraphQLinq 8 | { 9 | public class GraphContext 10 | { 11 | protected GraphContext(string baseUrl, string authorization) 12 | { 13 | BaseUrl = baseUrl; 14 | Authorization = authorization; 15 | ContractResolver = new DefaultContractResolver(); 16 | } 17 | 18 | public string BaseUrl { get; } 19 | public string Authorization { get; } 20 | public IContractResolver ContractResolver { get; set; } 21 | 22 | protected GraphCollectionQuery BuildCollectionQuery(object[] parameterValues, [CallerMemberName] string queryName = null) 23 | { 24 | var arguments = BuildDictionary(parameterValues, queryName); 25 | return new GraphCollectionQuery(this, queryName) { Arguments = arguments }; 26 | } 27 | 28 | protected GraphItemQuery BuildItemQuery(object[] parameterValues, [CallerMemberName] string queryName = null) 29 | { 30 | var arguments = BuildDictionary(parameterValues, queryName); 31 | return new GraphItemQuery(this, queryName) { Arguments = arguments }; 32 | } 33 | 34 | private Dictionary BuildDictionary(object[] parameterValues, string queryName) 35 | { 36 | var parameters = GetType().GetMethod(queryName, BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Instance).GetParameters(); 37 | var arguments = parameters.Zip(parameterValues, (info, value) => new { info.Name, Value = value }).ToDictionary(arg => arg.Name, arg => arg.Value); 38 | return arguments; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Tests/MethodIncludeQueryGenerationTests.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using HSL; 3 | using NUnit.Framework; 4 | 5 | namespace GraphQLinq.Tests 6 | { 7 | [TestFixture(Category = "Query generation tests")] 8 | public class MethodIncludeQueryGenerationTests 9 | { 10 | HslGraphContext hslGraphContext = new HslGraphContext(""); 11 | 12 | 13 | [Test] 14 | public void IncludingNavigationMethodQueryIncludesIncludedNavigationMethodWithNestedProperties() 15 | { 16 | var agencyQuery = hslGraphContext.Agency("248798") 17 | .Include(agency => agency.routes.Select(route => route.trips.Select(trip => trip.stoptimesForDate("20170427")))); 18 | 19 | Assert.That(agencyQuery.Query, Does.Contain("stoptimesForDate") 20 | .And.Contains(nameof(Stoptime.scheduledArrival)) 21 | .And.Contains(nameof(Stoptime.realtimeArrival))); 22 | } 23 | 24 | [Test] 25 | public void IncludingNavigationMethodQueryIncludesIncludedNavigationMethodParameter() 26 | { 27 | var agencyQuery = hslGraphContext.Agency("248798") 28 | .Include(agency => agency.routes.Select(route => route.trips.Select(trip => trip.stoptimesForDate("20170427")))); 29 | 30 | Assert.That(agencyQuery.Query, Does.Contain("$serviceDay1: String!").And.Contains("stoptimesForDate(serviceDay: $serviceDay1)")); 31 | } 32 | 33 | [Test] 34 | public void IncludingNavigationMethodQueryVariablesIncludesIncludedNavigationMethodArgument() 35 | { 36 | var agencyQuery = hslGraphContext.Agency("248798") 37 | .Include(agency => agency.routes.Select(route => route.trips.Select(trip => trip.stoptimesForDate("20170427")))); 38 | 39 | Assert.That(agencyQuery.QueryVariables, Does.ContainKey("serviceDay1").With.ContainValue("20170427")); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Scaffolding/RootSchemaObject.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Diagnostics; 3 | using System.Runtime.Serialization; 4 | using System.Text.Json.Serialization; 5 | 6 | namespace GraphQLinq.Scaffolding 7 | { 8 | public class RootSchemaObject 9 | { 10 | public Data Data { get; set; } 11 | } 12 | 13 | public class Data 14 | { 15 | [JsonPropertyName("__schema")] 16 | public Schema Schema { get; set; } 17 | } 18 | 19 | public class Schema 20 | { 21 | public List Types { get; set; } 22 | public GraphqlType QueryType { get; set; } 23 | public GraphqlType MutationType { get; set; } 24 | public GraphqlType? SubscriptionType { get; set; } 25 | } 26 | 27 | public class GraphqlType : BaseInfo 28 | { 29 | public TypeKind Kind { get; set; } 30 | public List EnumValues { get; set; } 31 | public List Fields { get; set; } 32 | public List InputFields { get; set; } 33 | public List Interfaces { get; set; } 34 | } 35 | 36 | [JsonConverter(typeof(JsonStringEnumMemberConverter))] 37 | public enum TypeKind 38 | { 39 | List, 40 | [EnumMember(Value = "NON_NULL")] 41 | NonNull, 42 | Scalar, 43 | Object, 44 | Interface, 45 | Union, 46 | Enum, 47 | [EnumMember(Value = "INPUT_OBJECT")] 48 | InputObject 49 | } 50 | 51 | public class EnumValue 52 | { 53 | public string Name { get; set; } 54 | } 55 | 56 | public class Field : BaseInfo 57 | { 58 | public FieldType Type { get; set; } 59 | public List Args { get; set; } 60 | } 61 | 62 | public class FieldType 63 | { 64 | public TypeKind Kind { get; set; } 65 | public string? Name { get; set; } 66 | public FieldType? OfType { get; set; } 67 | } 68 | 69 | public class Arg : BaseInfo 70 | { 71 | public FieldType Type { get; set; } 72 | } 73 | 74 | [DebuggerDisplay("Name = {" + nameof(Name) + "}")] 75 | public class BaseInfo 76 | { 77 | public string Name { get; set; } 78 | public string Description { get; set; } 79 | } 80 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/HslGraphContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using HSL; 4 | 5 | namespace GraphQLinq 6 | { 7 | public class HslGraphContext : GraphContext 8 | { 9 | public HslGraphContext(string baseUrl) : base(baseUrl, "") { } 10 | public HslGraphContext(string baseUrl, string authorization) : base(baseUrl, authorization) { } 11 | 12 | public GraphItemQuery Trip(string id) 13 | { 14 | var parameterValues = new object[] { id }; 15 | 16 | return BuildItemQuery(parameterValues, "trip"); 17 | } 18 | 19 | public GraphCollectionQuery Stations() 20 | { 21 | var parameterValues = new object[] { }; 22 | 23 | return BuildCollectionQuery(parameterValues, "stations"); 24 | } 25 | 26 | public GraphItemQuery Agency(string id) 27 | { 28 | var parameterValues = new object[] { id }; 29 | 30 | return BuildItemQuery(parameterValues, "agency"); 31 | } 32 | 33 | 34 | // query { 35 | //trip(id:"HSL:1055_20170501_To_1_1205") 36 | // { 37 | // id, 38 | // serviceId, 39 | // gtfsId, 40 | // pattern { 41 | // id, 42 | // name, 43 | // headsign, 44 | // geometry{ 45 | // lat 46 | // lon 47 | // } 48 | // }, 49 | // stoptimesForDate(serviceDay: "20170318"){ 50 | // headsign, 51 | // realtimeState 52 | // scheduledArrival 53 | 54 | // } 55 | // } 56 | // } 57 | } 58 | 59 | public static class QueryExtensions 60 | { 61 | public static List stoptimesForDate(this Trip trip, string serviceDay) 62 | { 63 | throw new NotImplementedException("This method is not implemented. It exists solely for query purposes."); 64 | } 65 | 66 | public static List stoptimesForServiceDate(this Stop stop, string date) 67 | { 68 | throw new NotImplementedException("This method is not implemented. It exists solely for query purposes."); 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Client/Client.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netstandard2.0 4 | Library 5 | false 6 | ./../output 7 | LICENSE.md 8 | https://github.com/Giorgi/GraphQLinq/ 9 | https://github.com/Giorgi/GraphQLinq/ 10 | 11 | true 12 | True 13 | 14 | git 15 | true 16 | true 17 | $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb 18 | Icon.png 19 | README-NuGet.md 20 | Strongly typed GraphQL queries with LINQ query syntax. 21 | 1.0.1-beta 22 | 1.0.0.1 23 | 1.0.0.1 24 | GraphQLinq.Client 25 | GraphQLinq.Client 26 | GraphQL LINQ json api 27 | Initial Release 28 | 29 | 30 | 31 | all 32 | runtime; build; native; contentfiles; analyzers; buildtransitive 33 | 34 | 35 | 36 | 37 | 38 | True 39 | 40 | 41 | 42 | True 43 | 44 | 45 | 46 | True 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/GraphQLinq.Scaffolding/Scaffolding.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net6 4 | Exe 5 | enable 6 | 7 | true 8 | GraphQLinq-Scaffold 9 | ./../output 10 | Giorgi Dalakishvili 11 | Copyright (c) 2017 - 2021 Giorgi Dalakishvili 12 | LICENSE.md 13 | 1.0.0.1 14 | 1.0.0.1 15 | git 16 | 17 | true 18 | True 19 | 1.0.1-beta 20 | false 21 | https://github.com/Giorgi/GraphQLinq/ 22 | Icon.png 23 | README-NuGet.md 24 | https://github.com/Giorgi/GraphQLinq/ 25 | GraphQL LINQ json api 26 | Initial Release 27 | Generate classes from GraphQL endpoint and write strongly typed queries with LINQ. 28 | GraphQLinq.Scaffolding 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | True 41 | 42 | 43 | 44 | True 45 | 46 | 47 | 48 | True 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /src/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | bash --version 2>&1 | head -n 1 4 | 5 | set -eo pipefail 6 | SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) 7 | 8 | ########################################################################### 9 | # CONFIGURATION 10 | ########################################################################### 11 | 12 | BUILD_PROJECT_FILE="$SCRIPT_DIR/build/_build.csproj" 13 | TEMP_DIRECTORY="$SCRIPT_DIR//.nuke/temp" 14 | 15 | DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json" 16 | DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh" 17 | DOTNET_CHANNEL="Current" 18 | 19 | export DOTNET_CLI_TELEMETRY_OPTOUT=1 20 | export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 21 | export DOTNET_MULTILEVEL_LOOKUP=0 22 | 23 | ########################################################################### 24 | # EXECUTION 25 | ########################################################################### 26 | 27 | function FirstJsonValue { 28 | perl -nle 'print $1 if m{"'"$1"'": "([^"]+)",?}' <<< "${@:2}" 29 | } 30 | 31 | # If dotnet CLI is installed globally and it matches requested version, use for execution 32 | if [ -x "$(command -v dotnet)" ] && dotnet --version &>/dev/null; then 33 | export DOTNET_EXE="$(command -v dotnet)" 34 | else 35 | # Download install script 36 | DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh" 37 | mkdir -p "$TEMP_DIRECTORY" 38 | curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL" 39 | chmod +x "$DOTNET_INSTALL_FILE" 40 | 41 | # If global.json exists, load expected version 42 | if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then 43 | DOTNET_VERSION=$(FirstJsonValue "version" "$(cat "$DOTNET_GLOBAL_FILE")") 44 | if [[ "$DOTNET_VERSION" == "" ]]; then 45 | unset DOTNET_VERSION 46 | fi 47 | fi 48 | 49 | # Install by channel or version 50 | DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix" 51 | if [[ -z ${DOTNET_VERSION+x} ]]; then 52 | "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path 53 | else 54 | "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path 55 | fi 56 | export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet" 57 | fi 58 | 59 | echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)" 60 | 61 | "$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet 62 | "$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@" 63 | -------------------------------------------------------------------------------- /src/GraphQLinq.Client/ExtensionsUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | 5 | namespace GraphQLinq 6 | { 7 | static class ExtensionsUtils 8 | { 9 | internal static bool IsValueTypeOrString(this Type type) 10 | { 11 | return type.IsValueType || type == typeof(string); 12 | } 13 | 14 | internal static bool IsList(this Type type) 15 | { 16 | return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List<>); 17 | } 18 | 19 | internal static bool HasNestedProperties(this Type type) 20 | { 21 | return !IsValueTypeOrString(type); 22 | } 23 | 24 | internal static Type GetTypeOrListType(this Type type) 25 | { 26 | if (type.IsList()) 27 | { 28 | var genericArguments = type.GetGenericArguments(); 29 | 30 | return genericArguments[0].GetTypeOrListType(); 31 | } 32 | 33 | return type; 34 | } 35 | 36 | internal static Expression RemoveConvert(this Expression expression) 37 | { 38 | while ((expression != null) 39 | && (expression.NodeType == ExpressionType.Convert 40 | || expression.NodeType == ExpressionType.ConvertChecked)) 41 | { 42 | expression = RemoveConvert(((UnaryExpression)expression).Operand); 43 | } 44 | 45 | return expression; 46 | } 47 | 48 | internal static string ToCamelCase(this string input) 49 | { 50 | if (char.IsLower(input[0])) 51 | { 52 | return input; 53 | } 54 | return input.Substring(0, 1).ToLower() + input.Substring(1); 55 | } 56 | 57 | internal static string ToGraphQlType(this Type type) 58 | { 59 | if (type == typeof(bool)) 60 | { 61 | return "Boolean"; 62 | } 63 | 64 | if (type == typeof(int)) 65 | { 66 | return "Int"; 67 | } 68 | 69 | if (type == typeof(string)) 70 | { 71 | return "String!"; 72 | } 73 | 74 | if (type == typeof(float)) 75 | { 76 | return "Float"; 77 | } 78 | 79 | if (type.IsList()) 80 | { 81 | var listType = type.GetTypeOrListType(); 82 | return "[" + ToGraphQlType(listType) + "]"; 83 | } 84 | 85 | return type.Name; 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Tests/CollectionQueryTests.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using HSL; 3 | using NUnit.Framework; 4 | 5 | namespace GraphQLinq.Tests 6 | { 7 | [TestFixture] 8 | [Category("Collection query")] 9 | [Category("Integration tests")] 10 | class CollectionQueryTests 11 | { 12 | readonly HslGraphContext hslGraphContext = new HslGraphContext("https://api.digitransit.fi/routing/v1/routers/finland/index/graphql"); 13 | 14 | [Test] 15 | public void SelectingNamesReturnsListOfNames() 16 | { 17 | var query = hslGraphContext.Stations().Select(l => l.name); 18 | 19 | var names = query.ToList(); 20 | 21 | Assert.Multiple(() => 22 | { 23 | CollectionAssert.IsNotEmpty(names); 24 | CollectionAssert.AllItemsAreNotNull(names); 25 | }); 26 | } 27 | 28 | [Test] 29 | public void SelectingNamesDoesNotReturnStops() 30 | { 31 | var query = hslGraphContext.Stations(); 32 | 33 | var stations = query.ToList(); 34 | 35 | Assert.That(stations, Is.All.Matches(l => l.stops == null)); 36 | } 37 | 38 | [Test] 39 | public void SelectingNamesAndIncludingStopsReturnsStops() 40 | { 41 | var query = hslGraphContext.Stations().Include(s => s.stops); 42 | 43 | var stations = query.ToList(); 44 | 45 | Assert.That(stations, Is.All.Matches(s => s.stops != null)); 46 | } 47 | 48 | [Test] 49 | public void SelectingNamesAndStopsReturnsStops() 50 | { 51 | var query = hslGraphContext.Stations().Select(location => new { location.name, location.stops }); 52 | 53 | var stations = query.ToList(); 54 | 55 | var stationsWithNullStops = stations.Where(s => s.stops == null).ToList(); 56 | CollectionAssert.IsEmpty(stationsWithNullStops); 57 | } 58 | 59 | [Test] 60 | public void SelectingNamesWithAliasAndStopsReturnsStopsAndNames() 61 | { 62 | var query = hslGraphContext.Stations().Select(location => new { StationName = location.name, location.stops }); 63 | 64 | var stations = query.ToList(); 65 | 66 | var stationsWithNullStops = stations.Where(s => s.stops == null).ToList(); 67 | var stationsWithNullCity = stations.Where(s => s.StationName == null).ToList(); 68 | 69 | Assert.Multiple(() => 70 | { 71 | CollectionAssert.IsEmpty(stationsWithNullStops); 72 | CollectionAssert.IsEmpty(stationsWithNullCity); 73 | }); 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /src/GraphQLinq.Scaffolding/ExtensionsUtils.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.CodeAnalysis; 2 | using Microsoft.CodeAnalysis.CSharp.Syntax; 3 | using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; 4 | 5 | namespace GraphQLinq.Scaffolding 6 | { 7 | static class ExtensionsUtils 8 | { 9 | internal static string ToCamelCase(this string input) 10 | { 11 | if (char.IsLower(input[0])) 12 | { 13 | return input; 14 | } 15 | return input.Substring(0, 1).ToLower() + input.Substring(1); 16 | } 17 | 18 | internal static string ToPascalCase(this string input) 19 | { 20 | if (char.IsUpper(input[0])) 21 | { 22 | return input; 23 | } 24 | return input.Substring(0, 1).ToUpper() + input.Substring(1); 25 | } 26 | 27 | internal static string NormalizeIfNeeded(this string input, CodeGenerationOptions options) 28 | { 29 | return options.NormalizeCasing ? input.ToPascalCase() : input; 30 | } 31 | } 32 | 33 | static class RoslynUtilities 34 | { 35 | internal static SyntaxNode GetTopLevelNode(string? @namespace) 36 | { 37 | return string.IsNullOrEmpty(@namespace) 38 | ? CompilationUnit() 39 | : NamespaceDeclaration(IdentifierName(@namespace)); 40 | } 41 | 42 | internal static SyntaxNode AddUsings(this SyntaxNode node, UsingDirectiveSyntax usingDirectiveSyntax) 43 | { 44 | switch (node) 45 | { 46 | case CompilationUnitSyntax compilationUnit: 47 | compilationUnit = compilationUnit.AddUsings(usingDirectiveSyntax); 48 | return compilationUnit; 49 | case NamespaceDeclarationSyntax namespaceDeclaration: 50 | namespaceDeclaration = namespaceDeclaration.AddUsings(usingDirectiveSyntax); 51 | return namespaceDeclaration; 52 | default: 53 | return node; 54 | } 55 | } 56 | 57 | internal static SyntaxNode AddMembers(this SyntaxNode node, MemberDeclarationSyntax memberDeclarationSyntax) 58 | { 59 | switch (node) 60 | { 61 | case CompilationUnitSyntax compilationUnit: 62 | compilationUnit = compilationUnit.AddMembers(memberDeclarationSyntax); 63 | return compilationUnit; 64 | case NamespaceDeclarationSyntax namespaceDeclaration: 65 | namespaceDeclaration = namespaceDeclaration.AddMembers(memberDeclarationSyntax); 66 | return namespaceDeclaration; 67 | default: 68 | return node; 69 | } 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Demo/Demo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net6 4 | Exe 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/GraphQLinq.Tests/SuperChargersTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using NUnit.Framework; 4 | 5 | namespace GraphQLinq.Tests 6 | { 7 | [Ignore("www.superchargers.io is down")] 8 | [TestFixture(Category = "Integration tests")] 9 | class SuperChargersTests 10 | { 11 | readonly List locationTypes = new List { LocationType.STORE, LocationType.SERVICE }; 12 | readonly SuperChargersGraphContext superChargersContext = new SuperChargersGraphContext("https://www.superchargers.io/graphql"); 13 | 14 | [Test] 15 | public void SelectingCitiesReturnsListOfCities() 16 | { 17 | var query = superChargersContext.Locations(type: locationTypes).Select(l => l.city); 18 | 19 | var locations = query.ToList(); 20 | 21 | CollectionAssert.IsNotEmpty(locations); 22 | CollectionAssert.AllItemsAreNotNull(locations); 23 | } 24 | 25 | [Test] 26 | public void SelectingLocationsDoesNotReturnPhones() 27 | { 28 | var query = superChargersContext.Locations(type: locationTypes); 29 | 30 | var locations = query.ToList(); 31 | Assert.That(locations, Is.All.Matches(l => l.salesPhone == null)); 32 | } 33 | 34 | [Test] 35 | public void SelectingLocationsAndIncludingPhonesReturnsPhones() 36 | { 37 | var query = superChargersContext.Locations(type: locationTypes).Include(location => location.salesPhone); 38 | 39 | var locations = query.ToList(); 40 | 41 | Assert.That(locations, Is.All.Matches(l => l.salesPhone != null)); 42 | } 43 | 44 | [Test] 45 | public void SelectingCitiesAndPhonesReturnsPhones() 46 | { 47 | var query = superChargersContext.Locations(type: locationTypes).Select(location => new { location.city, location.salesPhone }); 48 | 49 | var locations = query.ToList(); 50 | 51 | var locationsWithNullPhones = locations.Where(location => location.salesPhone == null).ToList(); 52 | CollectionAssert.IsEmpty(locationsWithNullPhones); 53 | } 54 | 55 | [Test] 56 | public void SelectingCitiesWithAliasAndPhonesReturnsPhonesAndCities() 57 | { 58 | var query = superChargersContext.Locations(type: locationTypes).Select(location => new { CityName = location.city, location.salesPhone }); 59 | 60 | var locations = query.ToList(); 61 | 62 | var locationsWithNullPhones = locations.Where(location => location.salesPhone == null).ToList(); 63 | var locationsWithNullCity = locations.Where(location => location.CityName == null).ToList(); 64 | 65 | Assert.Multiple(() => 66 | { 67 | CollectionAssert.IsEmpty(locationsWithNullPhones); 68 | CollectionAssert.IsEmpty(locationsWithNullCity); 69 | }); 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /src/build.ps1: -------------------------------------------------------------------------------- 1 | [CmdletBinding()] 2 | Param( 3 | [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] 4 | [string[]]$BuildArguments 5 | ) 6 | 7 | Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)" 8 | 9 | Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { Write-Error $_ -ErrorAction Continue; exit 1 } 10 | $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent 11 | 12 | ########################################################################### 13 | # CONFIGURATION 14 | ########################################################################### 15 | 16 | $BuildProjectFile = "$PSScriptRoot\build\_build.csproj" 17 | $TempDirectory = "$PSScriptRoot\\.nuke\temp" 18 | 19 | $DotNetGlobalFile = "$PSScriptRoot\\global.json" 20 | $DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1" 21 | $DotNetChannel = "Current" 22 | 23 | $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1 24 | $env:DOTNET_CLI_TELEMETRY_OPTOUT = 1 25 | $env:DOTNET_MULTILEVEL_LOOKUP = 0 26 | 27 | ########################################################################### 28 | # EXECUTION 29 | ########################################################################### 30 | 31 | function ExecSafe([scriptblock] $cmd) { 32 | & $cmd 33 | if ($LASTEXITCODE) { exit $LASTEXITCODE } 34 | } 35 | 36 | # If dotnet CLI is installed globally and it matches requested version, use for execution 37 | if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and ` 38 | $(dotnet --version) -and $LASTEXITCODE -eq 0) { 39 | $env:DOTNET_EXE = (Get-Command "dotnet").Path 40 | } 41 | else { 42 | # Download install script 43 | $DotNetInstallFile = "$TempDirectory\dotnet-install.ps1" 44 | New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null 45 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 46 | (New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile) 47 | 48 | # If global.json exists, load expected version 49 | if (Test-Path $DotNetGlobalFile) { 50 | $DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json) 51 | if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) { 52 | $DotNetVersion = $DotNetGlobal.sdk.version 53 | } 54 | } 55 | 56 | # Install by channel or version 57 | $DotNetDirectory = "$TempDirectory\dotnet-win" 58 | if (!(Test-Path variable:DotNetVersion)) { 59 | ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath } 60 | } else { 61 | ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath } 62 | } 63 | $env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe" 64 | } 65 | 66 | Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)" 67 | 68 | ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet } 69 | ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments } 70 | -------------------------------------------------------------------------------- /src/GraphQLinq.Generated/SpaceX/LaunchFind.cs: -------------------------------------------------------------------------------- 1 | namespace SpaceX 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public partial class LaunchFind 7 | { 8 | public float? Apoapsis_km { get; set; } 9 | public int? Block { get; set; } 10 | public string Cap_serial { get; set; } 11 | public string Capsule_reuse { get; set; } 12 | public int? Core_flight { get; set; } 13 | public string Core_reuse { get; set; } 14 | public string Core_serial { get; set; } 15 | public string Customer { get; set; } 16 | public float? Eccentricity { get; set; } 17 | public DateTime? End { get; set; } 18 | public DateTime? Epoch { get; set; } 19 | public string Fairings_recovered { get; set; } 20 | public string Fairings_recovery_attempt { get; set; } 21 | public string Fairings_reuse { get; set; } 22 | public string Fairings_reused { get; set; } 23 | public string Fairings_ship { get; set; } 24 | public string Gridfins { get; set; } 25 | public string Id { get; set; } 26 | public float? Inclination_deg { get; set; } 27 | public string Land_success { get; set; } 28 | public string Landing_intent { get; set; } 29 | public string Landing_type { get; set; } 30 | public string Landing_vehicle { get; set; } 31 | public DateTime? Launch_date_local { get; set; } 32 | public DateTime? Launch_date_utc { get; set; } 33 | public string Launch_success { get; set; } 34 | public string Launch_year { get; set; } 35 | public string Legs { get; set; } 36 | public float? Lifespan_years { get; set; } 37 | public float? Longitude { get; set; } 38 | public string Manufacturer { get; set; } 39 | public float? Mean_motion { get; set; } 40 | public string Mission_id { get; set; } 41 | public string Mission_name { get; set; } 42 | public string Nationality { get; set; } 43 | public int? Norad_id { get; set; } 44 | public string Orbit { get; set; } 45 | public string Payload_id { get; set; } 46 | public string Payload_type { get; set; } 47 | public float? Periapsis_km { get; set; } 48 | public float? Period_min { get; set; } 49 | public float? Raan { get; set; } 50 | public string Reference_system { get; set; } 51 | public string Regime { get; set; } 52 | public string Reused { get; set; } 53 | public string Rocket_id { get; set; } 54 | public string Rocket_name { get; set; } 55 | public string Rocket_type { get; set; } 56 | public string Second_stage_block { get; set; } 57 | public float? Semi_major_axis_km { get; set; } 58 | public string Ship { get; set; } 59 | public string Side_core1_reuse { get; set; } 60 | public string Side_core2_reuse { get; set; } 61 | public string Site_id { get; set; } 62 | public string Site_name_long { get; set; } 63 | public string Site_name { get; set; } 64 | public DateTime? Start { get; set; } 65 | public string Tbd { get; set; } 66 | public string Tentative_max_precision { get; set; } 67 | public string Tentative { get; set; } 68 | } 69 | } -------------------------------------------------------------------------------- /src/.nuke/build.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "title": "Build Schema", 4 | "$ref": "#/definitions/build", 5 | "definitions": { 6 | "build": { 7 | "type": "object", 8 | "properties": { 9 | "Configuration": { 10 | "type": "string", 11 | "description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)", 12 | "enum": [ 13 | "Debug", 14 | "Release" 15 | ] 16 | }, 17 | "Continue": { 18 | "type": "boolean", 19 | "description": "Indicates to continue a previously failed build attempt" 20 | }, 21 | "Help": { 22 | "type": "boolean", 23 | "description": "Shows the help text for this build assembly" 24 | }, 25 | "Host": { 26 | "type": "string", 27 | "description": "Host for execution. Default is 'automatic'", 28 | "enum": [ 29 | "AppVeyor", 30 | "AzurePipelines", 31 | "Bamboo", 32 | "Bitrise", 33 | "GitHubActions", 34 | "GitLab", 35 | "Jenkins", 36 | "SpaceAutomation", 37 | "TeamCity", 38 | "Terminal", 39 | "TravisCI" 40 | ] 41 | }, 42 | "NoLogo": { 43 | "type": "boolean", 44 | "description": "Disables displaying the NUKE logo" 45 | }, 46 | "Plan": { 47 | "type": "boolean", 48 | "description": "Shows the execution plan (HTML)" 49 | }, 50 | "Profile": { 51 | "type": "array", 52 | "description": "Defines the profiles to load", 53 | "items": { 54 | "type": "string" 55 | } 56 | }, 57 | "Root": { 58 | "type": "string", 59 | "description": "Root directory during build execution" 60 | }, 61 | "Skip": { 62 | "type": "array", 63 | "description": "List of targets to be skipped. Empty list skips all dependencies", 64 | "items": { 65 | "type": "string", 66 | "enum": [ 67 | "Clean", 68 | "Compile", 69 | "Pack", 70 | "Restore", 71 | "Test" 72 | ] 73 | } 74 | }, 75 | "Solution": { 76 | "type": "string", 77 | "description": "Path to a solution file that is automatically loaded" 78 | }, 79 | "Target": { 80 | "type": "array", 81 | "description": "List of targets to be invoked. Default is '{default_target}'", 82 | "items": { 83 | "type": "string", 84 | "enum": [ 85 | "Clean", 86 | "Compile", 87 | "Pack", 88 | "Restore", 89 | "Test" 90 | ] 91 | } 92 | }, 93 | "Verbosity": { 94 | "type": "string", 95 | "description": "Logging verbosity during build execution. Default is 'Normal'", 96 | "enum": [ 97 | "Minimal", 98 | "Normal", 99 | "Quiet", 100 | "Verbose" 101 | ] 102 | } 103 | } 104 | } 105 | } 106 | } -------------------------------------------------------------------------------- /src/GraphQLinq.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30711.63 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Demo", "GraphQLinq.Demo\Demo.csproj", "{D7CE01EE-342B-4836-BD9E-9BBF09A25263}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client", "GraphQLinq.Client\Client.csproj", "{AD9AA002-9EA5-4AA9-A5BD-2CB73E95F60B}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "GraphQLinq.Tests\Tests.csproj", "{2A292F0E-8ED7-4E4B-A03A-A0C1F6E8F8F8}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Generated", "GraphQLinq.Generated\Generated.csproj", "{3BD98755-AE1B-41DC-A680-DA39B2B1AC4A}" 13 | EndProject 14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Scaffolding", "GraphQLinq.Scaffolding\Scaffolding.csproj", "{B16D1D38-3CC3-4F8E-BC7D-5620370662AE}" 15 | EndProject 16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{F272EDAF-1736-4E58-A535-DAAC2EBA0DC4}" 17 | ProjectSection(SolutionItems) = preProject 18 | ..\docs\Images\Icon.png = ..\docs\Images\Icon.png 19 | ..\LICENSE.md = ..\LICENSE.md 20 | ..\README.md = ..\README.md 21 | EndProjectSection 22 | EndProject 23 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{F2ACC472-9FB9-4688-BC06-5C202F7C20E5}" 24 | EndProject 25 | Global 26 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 27 | Debug|Any CPU = Debug|Any CPU 28 | Release|Any CPU = Release|Any CPU 29 | EndGlobalSection 30 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 31 | {D7CE01EE-342B-4836-BD9E-9BBF09A25263}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 32 | {D7CE01EE-342B-4836-BD9E-9BBF09A25263}.Debug|Any CPU.Build.0 = Debug|Any CPU 33 | {D7CE01EE-342B-4836-BD9E-9BBF09A25263}.Release|Any CPU.ActiveCfg = Release|Any CPU 34 | {D7CE01EE-342B-4836-BD9E-9BBF09A25263}.Release|Any CPU.Build.0 = Release|Any CPU 35 | {AD9AA002-9EA5-4AA9-A5BD-2CB73E95F60B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 36 | {AD9AA002-9EA5-4AA9-A5BD-2CB73E95F60B}.Debug|Any CPU.Build.0 = Debug|Any CPU 37 | {AD9AA002-9EA5-4AA9-A5BD-2CB73E95F60B}.Release|Any CPU.ActiveCfg = Release|Any CPU 38 | {AD9AA002-9EA5-4AA9-A5BD-2CB73E95F60B}.Release|Any CPU.Build.0 = Release|Any CPU 39 | {2A292F0E-8ED7-4E4B-A03A-A0C1F6E8F8F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 40 | {2A292F0E-8ED7-4E4B-A03A-A0C1F6E8F8F8}.Debug|Any CPU.Build.0 = Debug|Any CPU 41 | {2A292F0E-8ED7-4E4B-A03A-A0C1F6E8F8F8}.Release|Any CPU.ActiveCfg = Release|Any CPU 42 | {2A292F0E-8ED7-4E4B-A03A-A0C1F6E8F8F8}.Release|Any CPU.Build.0 = Release|Any CPU 43 | {3BD98755-AE1B-41DC-A680-DA39B2B1AC4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 44 | {3BD98755-AE1B-41DC-A680-DA39B2B1AC4A}.Debug|Any CPU.Build.0 = Debug|Any CPU 45 | {3BD98755-AE1B-41DC-A680-DA39B2B1AC4A}.Release|Any CPU.ActiveCfg = Release|Any CPU 46 | {3BD98755-AE1B-41DC-A680-DA39B2B1AC4A}.Release|Any CPU.Build.0 = Release|Any CPU 47 | {B16D1D38-3CC3-4F8E-BC7D-5620370662AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 48 | {B16D1D38-3CC3-4F8E-BC7D-5620370662AE}.Debug|Any CPU.Build.0 = Debug|Any CPU 49 | {B16D1D38-3CC3-4F8E-BC7D-5620370662AE}.Release|Any CPU.ActiveCfg = Release|Any CPU 50 | {B16D1D38-3CC3-4F8E-BC7D-5620370662AE}.Release|Any CPU.Build.0 = Release|Any CPU 51 | {F2ACC472-9FB9-4688-BC06-5C202F7C20E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 52 | {F2ACC472-9FB9-4688-BC06-5C202F7C20E5}.Release|Any CPU.ActiveCfg = Release|Any CPU 53 | EndGlobalSection 54 | GlobalSection(SolutionProperties) = preSolution 55 | HideSolutionNode = FALSE 56 | EndGlobalSection 57 | GlobalSection(ExtensibilityGlobals) = postSolution 58 | SolutionGuid = {8C296DB2-F89F-43E3-8ADB-EAEFA266C843} 59 | EndGlobalSection 60 | EndGlobal 61 | -------------------------------------------------------------------------------- /src/build/Build.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Nuke.Common; 4 | using Nuke.Common.CI; 5 | using Nuke.Common.CI.AppVeyor; 6 | using Nuke.Common.Execution; 7 | using Nuke.Common.Git; 8 | using Nuke.Common.IO; 9 | using Nuke.Common.ProjectModel; 10 | using Nuke.Common.Tooling; 11 | using Nuke.Common.Tools.CoverallsNet; 12 | using Nuke.Common.Tools.Coverlet; 13 | using Nuke.Common.Tools.DotNet; 14 | using Nuke.Common.Utilities.Collections; 15 | using static Nuke.Common.IO.FileSystemTasks; 16 | using static Nuke.Common.Tools.CoverallsNet.CoverallsNetTasks; 17 | using static Nuke.Common.Tools.DotNet.DotNetTasks; 18 | 19 | [CheckBuildProjectConfigurations] 20 | [ShutdownDotNetAfterServerBuild] 21 | [AppVeyor(AppVeyorImage.VisualStudio2019, InvokedTargets = new[] { nameof(Test) }, Secrets = new[] { "COVERALLS_REPO_TOKEN:0wXxQdMQF5yHgpUe3heAG5zY2YYNBZYEF9FmgqoQi6b6IC0JibAA+idcnOkwTeEg" })] 22 | class Build : NukeBuild 23 | { 24 | /// Support plugins are available for: 25 | /// - JetBrains ReSharper https://nuke.build/resharper 26 | /// - JetBrains Rider https://nuke.build/rider 27 | /// - Microsoft VisualStudio https://nuke.build/visualstudio 28 | /// - Microsoft VSCode https://nuke.build/vscode 29 | 30 | public static int Main() => Execute(x => x.Compile); 31 | 32 | [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] 33 | readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release; 34 | 35 | [Solution] readonly Solution Solution; 36 | [GitRepository] readonly GitRepository GitRepository; 37 | 38 | readonly string[] ProjectsToPack = { "Client", "Scaffolding" }; 39 | 40 | AbsolutePath SourceDirectory => RootDirectory; 41 | AbsolutePath TestDirectory => SourceDirectory / "GraphQLinq.Tests"; 42 | AbsolutePath OutputDirectory => RootDirectory / "output"; 43 | AbsolutePath TestResultsDirectory => SourceDirectory / "TestResults"; 44 | 45 | Target Clean => _ => _ 46 | .Before(Restore) 47 | .Executes(() => 48 | { 49 | SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory); 50 | EnsureCleanDirectory(OutputDirectory); 51 | }); 52 | 53 | Target Restore => _ => _ 54 | .Executes(() => 55 | { 56 | DotNetRestore(s => s 57 | .SetProjectFile(Solution)); 58 | }); 59 | 60 | Target Compile => _ => _ 61 | .DependsOn(Restore) 62 | .Executes(() => 63 | { 64 | DotNetBuild(s => s 65 | .SetProjectFile(Solution) 66 | .SetConfiguration(Configuration) 67 | .EnableNoRestore()); 68 | }); 69 | 70 | Target Test => _ => _ 71 | .DependsOn(Compile) 72 | .Executes(() => 73 | { 74 | EnsureCleanDirectory(TestResultsDirectory); 75 | 76 | DotNetTest(s => s 77 | .SetProjectFile(TestDirectory / "Tests.csproj") 78 | .SetResultsDirectory(TestResultsDirectory) 79 | .SetLogger("trx") 80 | .EnableCollectCoverage() 81 | .SetCoverletOutputFormat(CoverletOutputFormat.opencover) 82 | .SetCoverletOutput("../TestResults/") 83 | .EnableNoRestore()); 84 | 85 | CoverallsNet(s => s.EnableOpenCover().SetInput(TestResultsDirectory / "coverage.opencover.xml")); 86 | }); 87 | 88 | Target Pack => _ => _ 89 | .DependsOn(Test) 90 | .Executes(() => 91 | { 92 | var projects = from project in ProjectsToPack 93 | select Solution.GetProject(project); 94 | 95 | DotNetPack(s => s 96 | .SetConfiguration("Release") 97 | .SetOutputDirectory(OutputDirectory) 98 | .SetProperty("SolutionName", Solution.Name) 99 | .CombineWith(projects, (settings, project) => settings.SetProject(project))); 100 | }); 101 | } 102 | -------------------------------------------------------------------------------- /src/GraphQLinq.Client/GraphQueryEnumerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Diagnostics.CodeAnalysis; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Net; 8 | using Newtonsoft.Json; 9 | using Newtonsoft.Json.Linq; 10 | using Newtonsoft.Json.Serialization; 11 | 12 | namespace GraphQLinq 13 | { 14 | class GraphQueryEnumerator : IEnumerator 15 | { 16 | private IEnumerator listEnumerator; 17 | 18 | private readonly string query; 19 | private readonly string baseUrl; 20 | private readonly string authorization; 21 | private readonly QueryType queryType; 22 | private readonly Func mapper; 23 | private readonly IContractResolver resolver; 24 | 25 | private const string DataPathPropertyName = "data"; 26 | private const string ErrorPathPropertyName = "errors"; 27 | 28 | internal GraphQueryEnumerator(GraphContext context, string query, QueryType queryType, Func mapper) 29 | { 30 | this.query = query; 31 | this.mapper = mapper; 32 | this.queryType = queryType; 33 | baseUrl = context.BaseUrl; 34 | resolver = context.ContractResolver ?? new DefaultContractResolver(); 35 | authorization = context.Authorization; 36 | } 37 | 38 | public void Dispose() 39 | { 40 | listEnumerator.Dispose(); 41 | } 42 | 43 | public bool MoveNext() 44 | { 45 | if (listEnumerator == null) 46 | { 47 | listEnumerator = DownloadData().GetEnumerator(); 48 | } 49 | 50 | return listEnumerator.MoveNext(); 51 | } 52 | 53 | private IEnumerable DownloadData() 54 | { 55 | var json = DownloadJson(); 56 | 57 | var jObject = JObject.Parse(json); 58 | 59 | if (jObject.SelectToken(ErrorPathPropertyName) != null) 60 | { 61 | var errors = jObject[ErrorPathPropertyName].ToObject>(); 62 | throw new GraphQueryExecutionException(errors, query); 63 | } 64 | 65 | var enumerable = jObject[DataPathPropertyName][GraphQueryBuilder.ResultAlias] 66 | .Select(token => 67 | { 68 | var jsonSerializer = new JsonSerializer { ContractResolver = resolver }; 69 | var jToken = queryType == QueryType.Collection ? token : token.Parent; 70 | 71 | if (mapper != null) 72 | { 73 | var result = jToken.ToObject(jsonSerializer); 74 | return mapper.Invoke(result); 75 | } 76 | 77 | return jToken.ToObject(jsonSerializer); 78 | }); 79 | 80 | return enumerable; 81 | } 82 | 83 | private string DownloadJson() 84 | { 85 | WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultCredentials; 86 | 87 | using (var webClient = new WebClient { Proxy = WebRequest.DefaultWebProxy }) 88 | { 89 | webClient.Headers.Add(HttpRequestHeader.ContentType, "application/json"); 90 | 91 | if (!string.IsNullOrEmpty(authorization)) 92 | { 93 | webClient.Headers.Add(HttpRequestHeader.Authorization, authorization); 94 | } 95 | 96 | try 97 | { 98 | return webClient.UploadString(baseUrl, query); 99 | } 100 | catch (WebException exception) 101 | { 102 | using (var responseStream = exception.Response?.GetResponseStream()) 103 | { 104 | using (var streamReader = new StreamReader(responseStream)) 105 | { 106 | return streamReader.ReadToEnd(); 107 | } 108 | } 109 | } 110 | } 111 | } 112 | 113 | [ExcludeFromCodeCoverage] 114 | public void Reset() 115 | { 116 | throw new NotImplementedException(); 117 | } 118 | 119 | public T Current => listEnumerator.Current; 120 | 121 | [ExcludeFromCodeCoverage] 122 | object IEnumerator.Current => Current; 123 | } 124 | } -------------------------------------------------------------------------------- /src/build/_build.csproj.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | DO_NOT_SHOW 3 | DO_NOT_SHOW 4 | DO_NOT_SHOW 5 | DO_NOT_SHOW 6 | Implicit 7 | Implicit 8 | ExpressionBody 9 | 0 10 | NEXT_LINE 11 | True 12 | False 13 | 120 14 | IF_OWNER_IS_SINGLE_LINE 15 | WRAP_IF_LONG 16 | False 17 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 18 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 19 | True 20 | True 21 | True 22 | True 23 | True 24 | True 25 | True 26 | True 27 | True 28 | -------------------------------------------------------------------------------- /src/GraphQLinq.Tests/SingleItemQueryTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using HSL; 4 | using NUnit.Framework; 5 | 6 | namespace GraphQLinq.Tests 7 | { 8 | [TestFixture] 9 | [Category("Single item query")] 10 | [Category("Integration tests")] 11 | class SingleItemQueryTests 12 | { 13 | const string AgencyId = "LINKKI:54836"; 14 | const string TripId = "OULU:0000880601314021"; 15 | 16 | readonly HslGraphContext hslGraphContext = new HslGraphContext("https://api.digitransit.fi/routing/v1/routers/finland/index/graphql"); 17 | 18 | [Test] 19 | public void SelectingSingleTripIdIsNotNull() 20 | { 21 | var tripId = hslGraphContext.Trip(TripId).Select(t => t.gtfsId).ToItem(); 22 | 23 | Assert.That(tripId, Is.Not.Null); 24 | } 25 | 26 | [Test] 27 | public void SelectingNestedPropertiesOfSingleTripNestedPropertiesAreNotNull() 28 | { 29 | var item = hslGraphContext.Trip(TripId) 30 | .Select(trip => new TripDetails(trip.gtfsId, trip.route.gtfsId, trip.pattern.geometry, trip.route.agency.name, trip.route.agency.phone)) 31 | .ToItem(); 32 | 33 | Assert.Multiple(() => 34 | { 35 | Assert.That(item.TripId, Is.Not.Null); 36 | Assert.That(item.RouteId, Is.Not.Null); 37 | Assert.That(item.Geometry, Is.Not.Null); 38 | Assert.That(item.Name, Is.Not.Null); 39 | //Assert.That(item.Phone, Is.Not.Null); 40 | }); 41 | } 42 | 43 | [Test] 44 | public void SelectingNestedPropertiesOfSingleTripAndCallingConstructorNestedPropertiesAreNotNull() 45 | { 46 | var item = hslGraphContext.Trip(TripId) 47 | .Select(trip => new TripDetails(trip.gtfsId, trip.route.gtfsId, trip.pattern.geometry, trip.route.agency.name, trip.route.agency.phone)) 48 | .ToItem(); 49 | 50 | Assert.Multiple(() => 51 | { 52 | Assert.That(item.TripId, Is.Not.Null); 53 | Assert.That(item.RouteId, Is.Not.Null); 54 | Assert.That(item.Geometry, Is.Not.Null); 55 | Assert.That(item.Name, Is.Not.Null); 56 | //Assert.That(item.Phone, Is.Not.Null); 57 | }); 58 | } 59 | 60 | [Test] 61 | public void SelectingThreeLevelNestedPropertyOfSingleTripNestedPropertyIsNotNull() 62 | { 63 | var routes = hslGraphContext.Trip(TripId).Select(trip => trip.route.agency.routes).ToItem(); 64 | 65 | CollectionAssert.IsNotEmpty(routes); 66 | } 67 | 68 | [Test] 69 | public void SelectingSingleTripNestedPropertyIsNull() 70 | { 71 | var trip = hslGraphContext.Trip(TripId).ToItem(); 72 | 73 | Assert.That(trip.pattern, Is.Null); 74 | } 75 | 76 | [Test] 77 | public void SelectingAndIncludingNestedPropertySingleTripNestedPropertyIsNotNull() 78 | { 79 | var pattern = hslGraphContext.Trip(TripId).Include(trip => trip.route).ToItem(); 80 | 81 | Assert.That(pattern.route, Is.Not.Null); 82 | } 83 | 84 | [Test] 85 | public void SelectingListOfListNestedPropertyShouldCheckListTypeRecursively() 86 | { 87 | Agency agency = null; 88 | 89 | Assert.DoesNotThrow(() => agency = hslGraphContext.Agency(AgencyId).Include(a => a.routes.Select(route => route.trips.Select(trip => trip.geometry))).ToItem()); 90 | 91 | if (agency == null) 92 | { 93 | Assert.Inconclusive($"Agency with id {AgencyId} not found"); 94 | } 95 | else 96 | { 97 | Assert.Multiple(() => 98 | { 99 | CollectionAssert.IsNotEmpty(agency.routes[0].trips[0].geometry); 100 | CollectionAssert.IsNotEmpty(agency.routes[1].trips[0].geometry); 101 | }); 102 | } 103 | } 104 | } 105 | 106 | class TripDetails 107 | { 108 | public string TripId { get; } 109 | public string RouteId { get; } 110 | public List Geometry { get; } 111 | public string Name { get; } 112 | public string Phone { get; } 113 | 114 | internal TripDetails(string tripId, string routeId, List geometry, string name, string phone) 115 | { 116 | TripId = tripId; 117 | RouteId = routeId; 118 | Geometry = geometry; 119 | Name = name; 120 | Phone = phone; 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | [Xx]64/ 19 | [Xx]86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | 24 | # Visual Studio 2015 cache/options directory 25 | .vs/ 26 | # Uncomment if you have tasks that create the project's static files in wwwroot 27 | #wwwroot/ 28 | 29 | # MSTest test Results 30 | [Tt]est[Rr]esult*/ 31 | [Bb]uild[Ll]og.* 32 | 33 | # NUNIT 34 | *.VisualState.xml 35 | TestResult.xml 36 | 37 | # Build Results of an ATL Project 38 | [Dd]ebugPS/ 39 | [Rr]eleasePS/ 40 | dlldata.c 41 | 42 | # DNX 43 | project.lock.json 44 | artifacts/ 45 | 46 | *_i.c 47 | *_p.c 48 | *_i.h 49 | *.ilk 50 | *.meta 51 | *.obj 52 | *.pch 53 | *.pdb 54 | *.pgc 55 | *.pgd 56 | *.rsp 57 | *.sbr 58 | *.tlb 59 | *.tli 60 | *.tlh 61 | *.tmp 62 | *.tmp_proj 63 | *.log 64 | *.vspscc 65 | *.vssscc 66 | .builds 67 | *.pidb 68 | *.svclog 69 | *.scc 70 | 71 | # Chutzpah Test files 72 | _Chutzpah* 73 | 74 | # Visual C++ cache files 75 | ipch/ 76 | *.aps 77 | *.ncb 78 | *.opendb 79 | *.opensdf 80 | *.sdf 81 | *.cachefile 82 | *.VC.db 83 | 84 | # Visual Studio profiler 85 | *.psess 86 | *.vsp 87 | *.vspx 88 | *.sap 89 | 90 | # TFS 2012 Local Workspace 91 | $tf/ 92 | 93 | # Guidance Automation Toolkit 94 | *.gpState 95 | 96 | # ReSharper is a .NET coding add-in 97 | _ReSharper*/ 98 | *.[Rr]e[Ss]harper 99 | *.DotSettings.user 100 | 101 | # JustCode is a .NET coding add-in 102 | .JustCode 103 | 104 | # TeamCity is a build add-in 105 | _TeamCity* 106 | 107 | # DotCover is a Code Coverage Tool 108 | *.dotCover 109 | 110 | # NCrunch 111 | _NCrunch_* 112 | .*crunch*.local.xml 113 | nCrunchTemp_* 114 | 115 | # MightyMoose 116 | *.mm.* 117 | AutoTest.Net/ 118 | 119 | # Web workbench (sass) 120 | .sass-cache/ 121 | 122 | # Installshield output folder 123 | [Ee]xpress/ 124 | 125 | # DocProject is a documentation generator add-in 126 | DocProject/buildhelp/ 127 | DocProject/Help/*.HxT 128 | DocProject/Help/*.HxC 129 | DocProject/Help/*.hhc 130 | DocProject/Help/*.hhk 131 | DocProject/Help/*.hhp 132 | DocProject/Help/Html2 133 | DocProject/Help/html 134 | 135 | # Click-Once directory 136 | publish/ 137 | 138 | # Publish Web Output 139 | *.[Pp]ublish.xml 140 | *.azurePubxml 141 | 142 | # TODO: Un-comment the next line if you do not want to checkin 143 | # your web deploy settings because they may include unencrypted 144 | # passwords 145 | #*.pubxml 146 | *.publishproj 147 | 148 | # NuGet Packages 149 | *.nupkg 150 | # The packages folder can be ignored because of Package Restore 151 | **/packages/* 152 | # except build/, which is used as an MSBuild target. 153 | !**/packages/build/ 154 | # Uncomment if necessary however generally it will be regenerated when needed 155 | #!**/packages/repositories.config 156 | # NuGet v3's project.json files produces more ignoreable files 157 | *.nuget.props 158 | *.nuget.targets 159 | 160 | # Microsoft Azure Build Output 161 | csx/ 162 | *.build.csdef 163 | 164 | # Microsoft Azure Emulator 165 | ecf/ 166 | rcf/ 167 | 168 | # Windows Store app package directory 169 | AppPackages/ 170 | BundleArtifacts/ 171 | 172 | # Visual Studio cache files 173 | # files ending in .cache can be ignored 174 | *.[Cc]ache 175 | # but keep track of directories ending in .cache 176 | !*.[Cc]ache/ 177 | 178 | # Others 179 | ClientBin/ 180 | [Ss]tyle[Cc]op.* 181 | ~$* 182 | *~ 183 | *.dbmdl 184 | *.dbproj.schemaview 185 | *.pfx 186 | *.publishsettings 187 | node_modules/ 188 | orleans.codegen.cs 189 | 190 | # RIA/Silverlight projects 191 | Generated_Code/ 192 | 193 | # Backup & report files from converting an old project file 194 | # to a newer Visual Studio version. Backup files are not needed, 195 | # because we have git ;-) 196 | _UpgradeReport_Files/ 197 | Backup*/ 198 | UpgradeLog*.XML 199 | UpgradeLog*.htm 200 | 201 | # SQL Server files 202 | *.mdf 203 | *.ldf 204 | 205 | # Business Intelligence projects 206 | *.rdl.data 207 | *.bim.layout 208 | *.bim_*.settings 209 | 210 | # Microsoft Fakes 211 | FakesAssemblies/ 212 | 213 | # GhostDoc plugin setting file 214 | *.GhostDoc.xml 215 | 216 | # Node.js Tools for Visual Studio 217 | .ntvs_analysis.dat 218 | 219 | # Visual Studio 6 build log 220 | *.plg 221 | 222 | # Visual Studio 6 workspace options file 223 | *.opt 224 | 225 | # Visual Studio LightSwitch build output 226 | **/*.HTMLClient/GeneratedArtifacts 227 | **/*.DesktopClient/GeneratedArtifacts 228 | **/*.DesktopClient/ModelManifest.xml 229 | **/*.Server/GeneratedArtifacts 230 | **/*.Server/ModelManifest.xml 231 | _Pvt_Extensions 232 | 233 | # LightSwitch generated files 234 | GeneratedArtifacts/ 235 | ModelManifest.xml 236 | 237 | # Paket dependency manager 238 | .paket/paket.exe 239 | 240 | # FAKE - F# Make 241 | .fake/ 242 | -------------------------------------------------------------------------------- /src/GraphQLinq.Tests/QueryGenerationTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace GraphQLinq.Tests 6 | { 7 | [TestFixture(Category = "Query generation tests")] 8 | public class QueryGenerationTests 9 | { 10 | SuperChargersGraphContext context = new SuperChargersGraphContext(""); 11 | HslGraphContext hslGraphContext = new HslGraphContext(""); 12 | 13 | [Test] 14 | public void SelectingSinglePropertyQueryIncludesSelectedProperty() 15 | { 16 | var locations = context.Locations().Select(l => l.city); 17 | 18 | Assert.That(locations.Query, Does.Contain("city")); 19 | } 20 | 21 | [Test] 22 | public void SelectingMultiplePropertiesQueryIncludesSelectedProperties() 23 | { 24 | var locations = context.Locations().Select(l => new { l.city, l.region }); 25 | 26 | Assert.That(locations.Query, Does.Contain("city").And.Contains("region")); 27 | } 28 | 29 | [Test] 30 | public void SelectingNavigationPropertyQueryIncludesPropertiesOfNavigationProperty() 31 | { 32 | var locations = context.Locations().Select(l => l.salesPhone); 33 | 34 | Assert.That(locations.Query, Does.Contain("number").And.Contains("label")); 35 | } 36 | 37 | [Test] 38 | public void SelectingListOfStringNavigationPropertyQueryDoesNotIncludesPropertiesOfNavigationProperty() 39 | { 40 | var locations = context.Locations().Select(l => l.locationType); 41 | 42 | Assert.That(locations.Query, Does.Not.Contain("length").And.Not.Contains("chars")); 43 | } 44 | 45 | [Test] 46 | public void SelectingPrimitiveAndNavigationPropertyQueryIncludesPropertiesOfNavigationProperty() 47 | { 48 | var locations = context.Locations().Select(l => new { l.salesPhone, l.city }); 49 | 50 | Assert.That(locations.Query, Does.Contain("number").And.Contains("label").And.Contains("city")); 51 | } 52 | 53 | [Test] 54 | public void SelectingPropertyQueryIncludesPropertyInCamelCase() 55 | { 56 | var locations = context.Locations().Select(l => l.Country); 57 | 58 | Assert.That(locations.Query, Does.Contain("country")); 59 | } 60 | 61 | [Test] 62 | public void SelectingAllPropertiesQueryDoesNotIncludeNavigationProperties() 63 | { 64 | var locations = context.Locations(); 65 | 66 | Assert.That(locations.Query, Does.Not.Contain(nameof(Location.salesPhone)).And.Not.Contains(nameof(Location.emails))); 67 | } 68 | 69 | [Test] 70 | public void IncludingNavigationPropertyQueryIncludesIncludedNavigationPropertyWithNestedProperties() 71 | { 72 | var locations = context.Locations().Include(l => l.salesPhone); 73 | 74 | Assert.That(locations.Query, Does.Contain(nameof(Location.salesPhone)) 75 | .And.Contains(nameof(Phone.label)) 76 | .And.Contains(nameof(Phone.number))); 77 | } 78 | 79 | [Test] 80 | public void IncludingNavigationPropertyWithSpecificPropertyQueryIncludesIncludedNavigationPropertySpecifiedProperty() 81 | { 82 | var locations = context.Locations().Include(l => l.salesPhone.Select(p => p.number)); 83 | 84 | Assert.That(locations.Query, Does.Contain(nameof(Location.salesPhone)) 85 | .And.Not.Contains(nameof(Phone.label)) 86 | .And.Contains(nameof(Phone.number))); 87 | } 88 | 89 | [Test] 90 | public void FilteringQueryWithScalarParameterGeneratedQueryIncludesPassedParameter() 91 | { 92 | var locations = context.Locations(openSoon: true).Select(l => l.city); 93 | 94 | Assert.Multiple(() => 95 | { 96 | Assert.That(locations.Query, Does.Contain("$openSoon: Boolean").And.Contain("openSoon: $openSoon")); 97 | CollectionAssert.Contains(locations.QueryVariables, new KeyValuePair("openSoon", true)); 98 | }); 99 | } 100 | 101 | [Test] 102 | public void FilteringQueryWithCollectionParameterGeneratedQueryIncludesPassedParameter() 103 | { 104 | var locations = context.Locations(type: new List { LocationType.SERVICE, LocationType.STORE }).Select(l => l.city); 105 | 106 | var query = locations.ToString(); 107 | 108 | Assert.That(query, Does.Contain("type\":[\"SERVICE\",\"STORE\"]")); 109 | } 110 | 111 | [Test] 112 | public void FilteringQueryWithCollectionParameterGeneratedQueryIncludesPassedParameterTypeInformation() 113 | { 114 | var locations = context.Locations(type: new List { LocationType.SERVICE, LocationType.STORE }).Select(l => l.city); 115 | 116 | var query = locations.ToString(); 117 | 118 | Assert.That(query, Does.Contain("$type: [LocationType]")); 119 | } 120 | 121 | [Test] 122 | public void FilteringQueryWithCollectionParameterGeneratedQueryFiltersLocationsByType() 123 | { 124 | var locations = context.Locations(type: new List { LocationType.SERVICE, LocationType.STORE }).Select(l => l.city); 125 | 126 | var query = locations.ToString(); 127 | 128 | Assert.That(query, Does.Contain("type: $type")); 129 | } 130 | 131 | [Test] 132 | public void SelectingListOfListNestedPropertyQueryShouldNotIncludeListProperties() 133 | { 134 | var agency = hslGraphContext.Agency("232919").Include(a => a.routes.Select(route => route.trips.Select(trip => trip.geometry))); 135 | 136 | Assert.That(agency.Query, Does.Not.Contain("capacity").And.Not.Contain("count").And.Not.Contain("item")); 137 | } 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /src/GraphQLinq.Scaffolding/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CommandLine; 3 | using System.CommandLine.Invocation; 4 | using System.IO; 5 | using System.Net.Http; 6 | using System.Net.Http.Json; 7 | using System.Text.Json; 8 | using System.Threading.Tasks; 9 | using Spectre.Console; 10 | 11 | namespace GraphQLinq.Scaffolding 12 | { 13 | class Program 14 | { 15 | private const string IntrospectionQuery = @"{ 16 | __schema { 17 | types { 18 | name 19 | interfaces { 20 | name 21 | } 22 | description 23 | kind 24 | enumValues { 25 | name 26 | } 27 | description 28 | fields { 29 | name 30 | description 31 | type { 32 | name 33 | kind 34 | ofType { 35 | name 36 | kind 37 | ofType { 38 | name 39 | kind 40 | ofType { 41 | name 42 | kind 43 | ofType { 44 | name 45 | kind 46 | ofType { 47 | name 48 | kind 49 | } 50 | } 51 | } 52 | } 53 | } 54 | } 55 | args { 56 | name 57 | description 58 | type { 59 | kind 60 | name 61 | description 62 | ofType { 63 | name 64 | kind 65 | ofType { 66 | name 67 | kind 68 | ofType { 69 | name 70 | kind 71 | } 72 | } 73 | } 74 | } 75 | } 76 | } 77 | inputFields { 78 | name 79 | description 80 | type { 81 | name 82 | kind 83 | ofType { 84 | name 85 | kind 86 | ofType { 87 | name 88 | kind 89 | ofType { 90 | name 91 | kind 92 | } 93 | } 94 | } 95 | } 96 | } 97 | } 98 | queryType { 99 | name 100 | } 101 | mutationType { 102 | name 103 | } 104 | subscriptionType { 105 | name 106 | } 107 | } 108 | } 109 | "; 110 | 111 | private static async Task Main(string[] args) 112 | { 113 | var generate = new RootCommand("Scaffold GraphQL client code") 114 | { 115 | new Argument("endpoint", "Endpoint of the GraphQL service"), 116 | new Option(new []{ "--output", "-o" }, () => "", "Output folder"), 117 | new Option(new []{ "--namespace", "-n" }, () => "","Namespace of generated classes"), 118 | new Option(new []{ "--context", "-c" }, () => "Query","Name of the generated context classes"), 119 | }; 120 | 121 | generate.Handler = CommandHandler.Create(HandleGenerate); 122 | 123 | await generate.InvokeAsync(args); 124 | } 125 | 126 | private static async Task HandleGenerate(Uri endpoint, string output, string @namespace, string context, IConsole console) 127 | { 128 | //var webClient = new WebClient(); 129 | //webClient.Headers.Add("Content-Type", "application/json"); 130 | //var downloadString = webClient.UploadString("endpoint", query); 131 | AnsiConsole.MarkupLine("[bold]Welcome to GraphQL Client Scaffolding tool[/]"); 132 | AnsiConsole.WriteLine(); 133 | 134 | string outputFolder = Path.IsPathRooted(output) ? output : Path.Combine(Environment.CurrentDirectory, output); 135 | 136 | AnsiConsole.MarkupLine("Scaffolding GraphQL client code for [bold]{0}[/] to [bold]{1}[/]", endpoint, outputFolder); 137 | 138 | var schema = await AnsiConsole.Status().StartAsync("Performing introspection", async ctx => 139 | { 140 | AnsiConsole.WriteLine("Running introspection query ..."); 141 | using var httpClient = new HttpClient(); 142 | using var responseMessage = await httpClient.PostAsJsonAsync(endpoint, new { query = IntrospectionQuery }); 143 | 144 | AnsiConsole.WriteLine("Reading and deserializing schema information ..."); 145 | var schemaJson = await responseMessage.Content.ReadAsStringAsync(); 146 | return JsonSerializer.Deserialize(schemaJson, new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); 147 | }); 148 | AnsiConsole.WriteLine(); 149 | 150 | var contextClassFullName = AnsiConsole.Status().Start($"Scaffolding GraphQL client code {endpoint}", statusContext => 151 | { 152 | var codeGenerationOptions = new CodeGenerationOptions 153 | { 154 | Namespace = @namespace, 155 | NormalizeCasing = true, 156 | OutputDirectory = outputFolder, 157 | ContextName = context 158 | }; 159 | 160 | var graphQLClassesGenerator = new GraphQLClassesGenerator(codeGenerationOptions); 161 | return graphQLClassesGenerator.GenerateClient(schema.Data.Schema, endpoint.AbsoluteUri); 162 | }); 163 | 164 | AnsiConsole.WriteLine(); 165 | AnsiConsole.MarkupLine("[bold]Scaffolding complete[/]"); 166 | AnsiConsole.MarkupLine("Use [bold]{0}[/] to run strongly typed LINQ queries", contextClassFullName); 167 | 168 | Console.ReadKey(); 169 | } 170 | } 171 | 172 | class CodeGenerationOptions 173 | { 174 | public string? Namespace { get; set; } = ""; 175 | public string ContextName { get; set; } = ""; 176 | public string OutputDirectory { get; set; } = ""; 177 | public bool NormalizeCasing { get; set; } 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /docs/README-NuGet.md: -------------------------------------------------------------------------------- 1 | # GraphQLinq 2 | 3 | LINQ to GraphQL - Strongly typed GraphQL queries with LINQ query syntax. 4 | 5 | ![Project Icon](docs/Images/Icon.png "GraphQLinq Project Icon") 6 | 7 | - [About The Project](#about-the-project) 8 | - [Getting Started](#getting-started) 9 | - [Installing Scaffolding Tool](#installing-scaffolding-tool) 10 | - [Scaffolding Client Code](#scaffolding-client-code) 11 | - [Install GraphQLinq NuGet Package](#install-graphqlinq-nuget-package) 12 | - [Running GraphQL Queries with LINQ](#running-graphql-queries-with-linq) 13 | - [Query all Primitive Properties of a Type](#query-all-primitive-properties-of-a-type) 14 | - [Query Specific Properties](#query-specific-properties) 15 | - [Include Navigation Properties](#include-navigation-properties) 16 | - [Pass Parameters to Queries and Compose Queries](#pass-parameters-to-queries-and-compose-queries) 17 | - [Include Multiple Levels of Navigation Properties](#include-multiple-levels-of-navigation-properties) 18 | - [View Generated Query](#view-generated-query) 19 | - [Roadmap](#roadmap) 20 | - [Contributing](#contributing) 21 | - [License](#license) 22 | 23 | ## About The Project 24 | 25 | GraphQLinq is a .NET tool for generating C# classes from a GraphQL endpoint and a .Net Standard library for writing strongly typed GraphQL queries with LINQ. 26 | 27 | With GraphQLinq you will: 28 | 29 | - Write strongly typed queries with LINQ. 30 | - Have your queries checked by the compiler. 31 | - Run queries and deserialize JSON response into strongly typed classes in a single method call. 32 | - View queries generated by LINQ to GraphQL. 33 | 34 | ## Getting Started 35 | 36 | ### Install Scaffolding Tool 37 | 38 | Before you starting writing queries, you need to generate classes from GraphQL types. This is done by `GraphQLinq.Scaffolding`, a .NET tool that is part of this project. 39 | 40 | To get the tool, open your favourite command shell and run 41 | 42 | ```sh 43 | dotnet tool install --global --version 1.0.0-beta GraphQLinq.Scaffolding 44 | ``` 45 | 46 | Running this command will install the `GraphQLinq.Scaffolding` tool and make it available globally for all projects. 47 | 48 | ### Scaffolding Client Code 49 | 50 | Next, navigate to the project where you want to add the classes and scaffold the client code. In this example, I will use the [SpaceX GraphQL Api](https://api.spacex.land/graphql) so run the following command: 51 | 52 | ```sh 53 | graphqlinq-scaffold https://api.spacex.land/graphql -o SpaceX -n SpaceX 54 | ``` 55 | 56 | The `o` option specifies the output directory for generated classes, and `n` specifies the namespace of the classes. 57 | 58 | ![Scaffolding](docs/Images/Scaffolding.gif "Scaffolding GraphQL Client") 59 | 60 | ### Install GraphQLinq NuGet Package 61 | 62 | Before writing the queries, you need to install the LINQ to GraphQL client library from NuGet. Run the following command to install it in the current project: 63 | 64 | ```sh 65 | dotnet add package GraphQLinq.Client --version 1.0.0-beta 66 | ``` 67 | 68 | ## Running GraphQL Queries with LINQ 69 | 70 | The scaffolding tool generates classes for types available in the GraphQL type system and a `QueryContext` class that serves as an entry point for running the queries. GraphQLinq supports running different kinds of queries. 71 | 72 | ### Query all Primitive Properties of a Type 73 | 74 | To query all properties of a type, simply run a query like this: 75 | 76 | ```cs 77 | var spaceXContext = new QueryContext(); 78 | 79 | var company = spaceXContext.Company().ToItem(); 80 | 81 | RenderCompanyDetails(company); 82 | ``` 83 | 84 | This will query all primitive and string properties of `Company`, but it won't query nested properties or collection type properties. 85 | 86 | ### Query Specific Properties 87 | 88 | If you want to query specific properties, including a navigation property, you can specify it with the `Select` method. You either map the projection to an existing type or an anonymous object (`Headquarters` is a nested property): 89 | 90 | ```cs 91 | var companySummaryAnonymous = spaceXContext.Company().Select(c => new { c.Ceo, c.Name, c.Headquarters }).ToItem(); 92 | 93 | //Use data class to select specific properties 94 | var companySummary = spaceXContext.Company().Select(c => new CompanySummary 95 | { 96 | Ceo = c.Ceo, 97 | Name = c.Name, 98 | Headquarters = c.Headquarters 99 | }).ToItem(); 100 | 101 | RenderCompanySummary(companySummary); 102 | ``` 103 | 104 | ### Include Navigation Properties 105 | 106 | You can also query navigation properties using the `Include` method. You can include several properties if you need, and you can also `Include` nested navigation properties: 107 | 108 | ```cs 109 | var companyWithHeadquartersAndLinks = spaceXContext.Company() 110 | .Include(info => info.Headquarters) 111 | .Include(info => info.Links).ToItem(); 112 | 113 | RenderCompanyDetailsAndLinks(companyWithHeadquartersAndLinks); 114 | ``` 115 | 116 | ### Pass Parameters to Queries and Compose Queries 117 | 118 | If the query has parameters, the generated method will have a parameter for each query parameter. 119 | 120 | This code will query for all `Missions` that included **Orbital ATK** as a manufacturer. It also builds a new query over the existing one that 121 | includes `Payloads` in the result. 122 | 123 | ```cs 124 | var missionsQuery = spaceXContext.Missions(new MissionsFind { Manufacturer = "Orbital ATK" }, null, null) 125 | .Include(mission => mission.Manufacturers); 126 | var missions = missionsQuery.ToList(); 127 | 128 | RenderMissions(missions); 129 | 130 | var missionsWithPayloads = missionsQuery.Include(mission => mission.Payloads).ToList(); 131 | 132 | RenderMissions(missionsWithPayloads, true); 133 | ``` 134 | 135 | ### Include Multiple Levels of Navigation Properties 136 | 137 | The `Include` method allows quering for multi-level nested properties too. For example, here is how to query for `Launches` and include Rocket's second stage payload manufacturer: 138 | 139 | ```cs 140 | //Launch_date_unix and Static_fire_date_unix need custom converter 141 | spaceXContext.ContractResolver = new SpaceXContractResolver(); 142 | 143 | var launches = spaceXContext.Launches(null, 10, 0, null, null) 144 | .Include(launch => launch.Links) 145 | .Include(launch => launch.Rocket) 146 | .Include(launch => launch.Rocket.Second_stage.Payloads.Select(payload => payload.Manufacturer)) 147 | .ToList(); 148 | 149 | RenderLaunches(launches); 150 | ``` 151 | 152 | ### View Generated Query 153 | 154 | You can view the GraphQL query and variables by using the `Query` and `Variables` property of the `GraphQuery` class. The `ToString()` method of the `GraphQuery` class returns the query and the variables combined: 155 | 156 | ```cs 157 | var missionsQuery = spaceXContext.Missions(new MissionsFind { Manufacturer = "Orbital ATK" }, null, null) 158 | .Include(mission => mission.Manufacturers); 159 | 160 | var query = missionsQuery.Query; 161 | var fullQuery = missionsQuery.ToString(); 162 | ``` 163 | 164 | If you run the above code `query` will be equal to 165 | 166 | ```js 167 | query ($find: MissionsFind) { result: missions (find: $find) { 168 | description 169 | id 170 | name 171 | twitter 172 | website 173 | wikipedia 174 | manufacturers 175 | }} 176 | ``` 177 | 178 | and the content of `fullQuery` will be: 179 | 180 | ```json 181 | {"query":"query ($find: MissionsFind) { result: missions (find: $find) { 182 | description 183 | id 184 | name 185 | twitter 186 | website 187 | wikipedia 188 | manufacturers 189 | }}","variables":{"find":{"manufacturer":"Orbital ATK"}}} 190 | ``` 191 | 192 | ## Roadmap 193 | 194 | See the [open issues](https://github.com/Giorgi/GraphQLinq/issues) for a list of proposed features and known issues. 195 | 196 | ## Contributing 197 | 198 | If you encounter a bug or have a feature request, please use the [Issue Tracker](https://github.com/Giorgi/GraphQLinq/issues/new). The project is also open to contributions, so feel free to fork the project and open pull requests. 199 | 200 | ## License 201 | 202 | Copyright © Giorgi Dalakishvili 203 | 204 | Distributed under the Apache License. See [License](License.md) for more information. 205 | -------------------------------------------------------------------------------- /src/GraphQLinq.Client/GraphQuery.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Diagnostics.CodeAnalysis; 5 | using System.Linq; 6 | using System.Linq.Expressions; 7 | using System.Reflection; 8 | 9 | namespace GraphQLinq 10 | { 11 | public abstract class GraphQuery 12 | { 13 | private readonly GraphContext context; 14 | private readonly Lazy lazyQuery; 15 | private readonly GraphQueryBuilder queryBuilder = new GraphQueryBuilder(); 16 | 17 | internal string QueryName { get; } 18 | internal LambdaExpression Selector { get; private set; } 19 | internal List Includes { get; private set; } = new List(); 20 | internal Dictionary Arguments { get; set; } = new Dictionary(); 21 | 22 | internal GraphQuery(GraphContext graphContext, string queryName) 23 | { 24 | QueryName = queryName; 25 | context = graphContext; 26 | 27 | lazyQuery = new Lazy(() => queryBuilder.BuildQuery(this, Includes)); 28 | } 29 | 30 | public override string ToString() 31 | { 32 | return lazyQuery.Value.FullQuery; 33 | } 34 | 35 | public string Query => lazyQuery.Value.Query; 36 | public IReadOnlyDictionary QueryVariables => lazyQuery.Value.Variables; 37 | 38 | protected GraphQuery Clone() 39 | { 40 | var genericQueryType = GetType().GetGenericTypeDefinition(); 41 | var genericArguments = GetType().GetGenericArguments(); 42 | var cloneType = genericQueryType.MakeGenericType(typeof(TR), genericArguments[1]); 43 | 44 | var instance = (GraphQuery)Activator.CreateInstance(cloneType, context, QueryName); 45 | 46 | instance.Arguments = Arguments; 47 | instance.Selector = Selector; 48 | instance.Includes = Includes.ToList(); 49 | 50 | return instance; 51 | } 52 | 53 | internal static IncludeDetails ParseIncludePath(Expression expression) 54 | { 55 | string path = null; 56 | var withoutConvert = expression.RemoveConvert(); // Removes boxing 57 | var memberExpression = withoutConvert as MemberExpression; 58 | var callExpression = withoutConvert as MethodCallExpression; 59 | 60 | if (memberExpression != null) 61 | { 62 | var parentPath = ParseIncludePath(memberExpression.Expression); 63 | if (parentPath == null) 64 | { 65 | return null; 66 | } 67 | 68 | var thisPart = memberExpression.Member.Name; 69 | path = parentPath.Path == null ? thisPart : (parentPath.Path + "." + thisPart); 70 | } 71 | else if (callExpression != null) 72 | { 73 | if (callExpression.Method.Name == "Select" && callExpression.Arguments.Count == 2) 74 | { 75 | var parentPath = ParseIncludePath(callExpression.Arguments[0]); 76 | if (parentPath == null) 77 | { 78 | return null; 79 | } 80 | 81 | if (parentPath.Path != null) 82 | { 83 | var subExpression = callExpression.Arguments[1] as LambdaExpression; 84 | if (subExpression != null) 85 | { 86 | var thisPath = ParseIncludePath(subExpression.Body); 87 | if (thisPath == null) 88 | { 89 | return null; 90 | } 91 | 92 | if (thisPath.Path != null) 93 | { 94 | path = parentPath.Path + "." + thisPath.Path; 95 | var result = new IncludeDetails(parentPath.MethodIncludes.Union(thisPath.MethodIncludes)) { Path = path }; 96 | 97 | return result; 98 | } 99 | } 100 | } 101 | } 102 | if (callExpression.Method.DeclaringType?.Name == "QueryExtensions") 103 | { 104 | var parentPath = ParseIncludePath(callExpression.Arguments[0]); 105 | if (parentPath == null) 106 | { 107 | return null; 108 | } 109 | 110 | path = parentPath.Path == null ? callExpression.Method.Name : parentPath.Path + "." + callExpression.Method.Name; 111 | 112 | var arguments = callExpression.Arguments.Zip(callExpression.Method.GetParameters(), (argument, parameter) => new 113 | { 114 | Argument = argument, 115 | parameter.Name 116 | }).Skip(1).ToDictionary(arg => arg.Name, arg => (arg.Argument as ConstantExpression).Value); 117 | 118 | var result = new IncludeDetails { Path = path }; 119 | result.MethodIncludes.Add(new IncludeMethodDetails 120 | { 121 | Method = callExpression.Method, 122 | Parameters = arguments 123 | }); 124 | result.MethodIncludes.AddRange(parentPath.MethodIncludes); 125 | return result; 126 | } 127 | 128 | return null; 129 | } 130 | 131 | return new IncludeDetails { Path = path }; 132 | } 133 | 134 | protected GraphQuery BuildInclude(Expression> path) 135 | { 136 | var include = ParseIncludePath(path.Body); 137 | if (include?.Path == null) 138 | { 139 | throw new ArgumentException("Invalid Include Path Expression", nameof(path)); 140 | } 141 | 142 | var graphQuery = Clone(); 143 | graphQuery.Includes.Add(include); 144 | 145 | return graphQuery; 146 | } 147 | 148 | protected GraphQuery BuildSelect(Expression> resultSelector) 149 | { 150 | if (resultSelector.NodeType != ExpressionType.Lambda) 151 | { 152 | throw new ArgumentException($"{resultSelector} must be lambda expression", nameof(resultSelector)); 153 | } 154 | 155 | var graphQuery = Clone(); 156 | graphQuery.Selector = resultSelector; 157 | 158 | return graphQuery; 159 | } 160 | 161 | internal IEnumerator BuildEnumerator(QueryType queryType) 162 | { 163 | var query = lazyQuery.Value; 164 | 165 | var mapper = (Func)Selector?.Compile(); 166 | 167 | return new GraphQueryEnumerator(context, query.FullQuery, queryType, mapper); 168 | } 169 | } 170 | 171 | public abstract class GraphItemQuery : GraphQuery 172 | { 173 | protected GraphItemQuery(GraphContext graphContext, string queryName) : base(graphContext, queryName) { } 174 | 175 | public GraphItemQuery Include(Expression> path) 176 | { 177 | return (GraphItemQuery)BuildInclude(path); 178 | } 179 | 180 | public GraphItemQuery Select(Expression> resultSelector) 181 | { 182 | return (GraphItemQuery)BuildSelect(resultSelector); 183 | } 184 | 185 | public abstract T ToItem(); 186 | } 187 | 188 | public abstract class GraphCollectionQuery : GraphQuery, IEnumerable 189 | { 190 | protected GraphCollectionQuery(GraphContext graphContext, string queryName) : base(graphContext, queryName) { } 191 | 192 | public abstract IEnumerator GetEnumerator(); 193 | 194 | [ExcludeFromCodeCoverage] 195 | IEnumerator IEnumerable.GetEnumerator() 196 | { 197 | return GetEnumerator(); 198 | } 199 | 200 | public GraphCollectionQuery Include(Expression> path) 201 | { 202 | return (GraphCollectionQuery)BuildInclude(path); 203 | } 204 | 205 | public GraphCollectionQuery Select(Expression> resultSelector) 206 | { 207 | return (GraphCollectionQuery)BuildSelect(resultSelector); 208 | } 209 | } 210 | 211 | public class GraphItemQuery : GraphItemQuery 212 | { 213 | public GraphItemQuery(GraphContext graphContext, string queryName) : base(graphContext, queryName) 214 | { 215 | } 216 | 217 | public override T ToItem() 218 | { 219 | using (var enumerator = BuildEnumerator(QueryType.Item)) 220 | { 221 | enumerator.MoveNext(); 222 | return enumerator.Current; 223 | } 224 | } 225 | } 226 | 227 | public class GraphCollectionQuery : GraphCollectionQuery 228 | { 229 | public GraphCollectionQuery(GraphContext graphContext, string queryName) : base(graphContext, queryName) 230 | { 231 | } 232 | 233 | public override IEnumerator GetEnumerator() 234 | { 235 | return BuildEnumerator(QueryType.Collection); 236 | } 237 | } 238 | 239 | internal enum QueryType 240 | { 241 | Item, 242 | Collection 243 | } 244 | 245 | class IncludeDetails 246 | { 247 | public IncludeDetails() 248 | { 249 | 250 | } 251 | public IncludeDetails(IEnumerable methodIncludes) 252 | { 253 | MethodIncludes = methodIncludes.ToList(); 254 | } 255 | 256 | public string Path { get; set; } 257 | public List MethodIncludes { get; } = new List(); 258 | } 259 | 260 | class IncludeMethodDetails 261 | { 262 | public MethodInfo Method { get; set; } 263 | public Dictionary Parameters { get; set; } 264 | 265 | public override string ToString() 266 | { 267 | return Method.Name; 268 | } 269 | } 270 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Client/GraphQueryBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | using System.Reflection; 6 | using Newtonsoft.Json; 7 | using Newtonsoft.Json.Converters; 8 | using Newtonsoft.Json.Serialization; 9 | 10 | namespace GraphQLinq 11 | { 12 | class GraphQueryBuilder 13 | { 14 | private const string QueryTemplate = @"query {0} {{ {1}: {2} {3} {{ {4} }}}}"; 15 | internal const string ResultAlias = "result"; 16 | 17 | public GraphQLQuery BuildQuery(GraphQuery graphQuery, List includes) 18 | { 19 | var selectClause = ""; 20 | 21 | var passedArguments = graphQuery.Arguments.Where(pair => pair.Value != null).ToList(); 22 | var queryVariables = passedArguments.ToDictionary(pair => pair.Key, pair => pair.Value); 23 | 24 | if (graphQuery.Selector != null) 25 | { 26 | var body = graphQuery.Selector.Body; 27 | 28 | var padding = new string(' ', 4); 29 | 30 | var fields = new List(); 31 | 32 | switch (body) 33 | { 34 | case MemberExpression memberExpression: 35 | var member = memberExpression.Member; 36 | selectClause = BuildMemberAccessSelectClause(body, selectClause, padding, member.Name); 37 | break; 38 | 39 | case NewExpression newExpression: 40 | foreach (var argument in newExpression.Arguments.OfType()) 41 | { 42 | var selectField = BuildMemberAccessSelectClause(argument, selectClause, padding, argument.Member.Name); 43 | fields.Add(selectField); 44 | } 45 | selectClause = string.Join(Environment.NewLine, fields); 46 | break; 47 | 48 | case MemberInitExpression memberInitExpression: 49 | foreach (var argument in memberInitExpression.Bindings.OfType()) 50 | { 51 | var selectField = BuildMemberAccessSelectClause(argument.Expression, selectClause, padding, argument.Member.Name); 52 | fields.Add(selectField); 53 | } 54 | selectClause = string.Join(Environment.NewLine, fields); 55 | break; 56 | default: 57 | throw new NotSupportedException($"Selector of type {body.NodeType} is not implemented yet"); 58 | } 59 | } 60 | else 61 | { 62 | var select = BuildSelectClauseForType(typeof(T), includes); 63 | selectClause = select.SelectClause; 64 | 65 | foreach (var item in select.IncludeArguments) 66 | { 67 | queryVariables.Add(item.Key, item.Value); 68 | } 69 | } 70 | 71 | selectClause = Environment.NewLine + selectClause + Environment.NewLine; 72 | 73 | var queryParameters = passedArguments.Any() ? $"({string.Join(", ", passedArguments.Select(pair => $"{pair.Key}: ${pair.Key}"))})" : ""; 74 | var queryParameterTypes = queryVariables.Any() ? $"({string.Join(", ", queryVariables.Select(pair => $"${pair.Key}: {pair.Value.GetType().ToGraphQlType()}"))})" : ""; 75 | 76 | var graphQLQuery = string.Format(QueryTemplate, queryParameterTypes, ResultAlias, graphQuery.QueryName, queryParameters, selectClause); 77 | 78 | var dictionary = new Dictionary { { "query", graphQLQuery }, { "variables", queryVariables } }; 79 | 80 | var json = JsonConvert.SerializeObject(dictionary, new JsonSerializerSettings 81 | { 82 | NullValueHandling = NullValueHandling.Ignore, 83 | ContractResolver = new DefaultContractResolver 84 | { 85 | NamingStrategy = new CamelCaseNamingStrategy() 86 | }, 87 | Converters = new List { new StringEnumConverter() } 88 | }); 89 | 90 | return new GraphQLQuery(graphQLQuery, queryVariables, json); 91 | } 92 | 93 | private static string BuildMemberAccessSelectClause(Expression body, string selectClause, string padding, string alias) 94 | { 95 | if (body is MemberExpression memberExpression) 96 | { 97 | var member = memberExpression.Member as PropertyInfo; 98 | 99 | if (member != null) 100 | { 101 | if (string.IsNullOrEmpty(selectClause)) 102 | { 103 | selectClause = $"{padding}{alias}: {member.Name.ToCamelCase()}"; 104 | 105 | if (!member.PropertyType.GetTypeOrListType().IsValueTypeOrString()) 106 | { 107 | var fieldForProperty = BuildSelectClauseForType(member.PropertyType.GetTypeOrListType(), 3); 108 | selectClause = $"{selectClause} {{{Environment.NewLine}{fieldForProperty}{Environment.NewLine}{padding}}}"; 109 | } 110 | } 111 | else 112 | { 113 | selectClause = $"{member.Name.ToCamelCase()} {{ {Environment.NewLine}{selectClause}}}"; 114 | } 115 | return BuildMemberAccessSelectClause(memberExpression.Expression, selectClause, padding, ""); 116 | } 117 | return selectClause; 118 | } 119 | return selectClause; 120 | } 121 | 122 | private static string BuildSelectClauseForType(Type targetType, int depth = 1) 123 | { 124 | var propertyInfos = targetType.GetProperties(); 125 | 126 | var propertiesToInclude = propertyInfos.Where(info => !info.PropertyType.HasNestedProperties()); 127 | 128 | var selectClause = string.Join(Environment.NewLine, propertiesToInclude.Select(info => new string(' ', depth * 2) + info.Name.ToCamelCase())); 129 | 130 | return selectClause; 131 | } 132 | 133 | private static SelectClauseDetails BuildSelectClauseForType(Type targetType, List includes) 134 | { 135 | var selectClause = BuildSelectClauseForType(targetType); 136 | var includeVariables = new Dictionary(); 137 | 138 | for (var index = 0; index < includes.Count; index++) 139 | { 140 | var include = includes[index]; 141 | var prefix = includes.Count == 1 ? "" : index.ToString(); 142 | 143 | var fieldsFromInclude = BuildSelectClauseForInclude(targetType, include, includeVariables, prefix); 144 | selectClause = selectClause + Environment.NewLine + fieldsFromInclude; 145 | } 146 | return new SelectClauseDetails { SelectClause = selectClause, IncludeArguments = includeVariables }; 147 | } 148 | 149 | private static string BuildSelectClauseForInclude(Type targetType, IncludeDetails includeDetails, Dictionary includeVariables, string parameterPrefix = "", int parameterIndex = 0, int depth = 1) 150 | { 151 | var include = includeDetails.Path; 152 | if (string.IsNullOrEmpty(include)) 153 | { 154 | return BuildSelectClauseForType(targetType, depth); 155 | } 156 | var leftPadding = new string(' ', depth * 2); 157 | 158 | var dotIndex = include.IndexOf(".", StringComparison.InvariantCultureIgnoreCase); 159 | 160 | var currentIncludeName = dotIndex >= 0 ? include.Substring(0, dotIndex) : include; 161 | 162 | Type propertyType; 163 | var propertyInfo = targetType.GetProperty(currentIncludeName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance); 164 | 165 | var includeName = currentIncludeName.ToCamelCase(); 166 | 167 | var includeMethodInfo = includeDetails.MethodIncludes.Count > parameterIndex ? includeDetails.MethodIncludes[parameterIndex].Method : null; 168 | var includeByMethod = includeMethodInfo != null && currentIncludeName == includeMethodInfo.Name && propertyInfo.PropertyType == includeMethodInfo.ReturnType; 169 | 170 | if (includeByMethod) 171 | { 172 | var methodDetails = includeDetails.MethodIncludes[parameterIndex]; 173 | parameterIndex++; 174 | 175 | propertyType = methodDetails.Method.ReturnType.GetTypeOrListType(); 176 | 177 | var includeMethodParams = methodDetails.Parameters.Where(pair => pair.Value != null).ToList(); 178 | includeName = methodDetails.Method.Name.ToCamelCase(); 179 | 180 | if (includeMethodParams.Any()) 181 | { 182 | var includeParameters = string.Join(", ", includeMethodParams.Select(pair => pair.Key + ": $" + pair.Key + parameterPrefix + parameterIndex)); 183 | includeName = $"{includeName}({includeParameters})"; 184 | 185 | foreach (var item in includeMethodParams) 186 | { 187 | includeVariables.Add(item.Key + parameterPrefix + parameterIndex, item.Value); 188 | } 189 | } 190 | } 191 | else 192 | { 193 | propertyType = propertyInfo.PropertyType.GetTypeOrListType(); 194 | } 195 | 196 | if (propertyType.IsValueTypeOrString()) 197 | { 198 | return leftPadding + includeName; 199 | } 200 | 201 | var restOfTheInclude = new IncludeDetails(includeDetails.MethodIncludes) { Path = dotIndex >= 0 ? include.Substring(dotIndex + 1) : "" }; 202 | 203 | var fieldsFromInclude = BuildSelectClauseForInclude(propertyType, restOfTheInclude, includeVariables, parameterPrefix, parameterIndex, depth + 1); 204 | fieldsFromInclude = $"{leftPadding}{includeName} {{{Environment.NewLine}{fieldsFromInclude}{Environment.NewLine}{leftPadding}}}"; 205 | return fieldsFromInclude; 206 | } 207 | } 208 | 209 | class GraphQLQuery 210 | { 211 | public GraphQLQuery(string query, IReadOnlyDictionary variables, string fullQuery) 212 | { 213 | Query = query; 214 | Variables = variables; 215 | FullQuery = fullQuery; 216 | } 217 | 218 | public string Query { get; } 219 | public string FullQuery { get; } 220 | public IReadOnlyDictionary Variables { get; } 221 | } 222 | 223 | class SelectClauseDetails 224 | { 225 | public string SelectClause { get; set; } 226 | public Dictionary IncludeArguments { get; set; } 227 | } 228 | } -------------------------------------------------------------------------------- /src/GraphQLinq.Demo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using Newtonsoft.Json; 6 | using Newtonsoft.Json.Converters; 7 | using Newtonsoft.Json.Serialization; 8 | using SpaceX; 9 | using Spectre.Console; 10 | using Spectre.Console.Rendering; 11 | 12 | namespace GraphQLinq.Demo 13 | { 14 | class Program 15 | { 16 | static void Main(string[] args) 17 | { 18 | SpaceXQueryExamples(); 19 | } 20 | 21 | private static void SpaceXQueryExamples() 22 | { 23 | var spaceXContext = new QueryContext(); 24 | 25 | #region Company details 26 | var company = spaceXContext.Company().ToItem(); 27 | 28 | RenderCompanyDetails(company); 29 | #endregion 30 | 31 | #region Specific properties of company 32 | //Use an anonymous type to select specific properties 33 | var companySummaryAnonymous = spaceXContext.Company().Select(c => new { c.Ceo, c.Name, c.Headquarters }).ToItem(); 34 | 35 | //Use data class to select specific properties 36 | var companySummary = spaceXContext.Company().Select(c => new CompanySummary 37 | { 38 | Ceo = c.Ceo, 39 | Name = c.Name, 40 | Headquarters = c.Headquarters 41 | }).ToItem(); 42 | 43 | RenderCompanySummary(companySummary); 44 | #endregion 45 | 46 | #region Include navigation properties 47 | var companyWithHeadquartersAndLinks = spaceXContext.Company() 48 | .Include(info => info.Headquarters) 49 | .Include(info => info.Links).ToItem(); 50 | 51 | RenderCompanyDetailsAndLinks(companyWithHeadquartersAndLinks); 52 | #endregion 53 | 54 | #region Filter missions, compose queries 55 | var missionsQuery = spaceXContext.Missions(new MissionsFind { Manufacturer = "Orbital ATK" }, null, null) 56 | .Include(mission => mission.Manufacturers); 57 | var missions = missionsQuery.ToList(); 58 | 59 | RenderMissions(missions); 60 | 61 | var missionsWithPayloads = missionsQuery.Include(mission => mission.Payloads).ToList(); 62 | 63 | RenderMissions(missionsWithPayloads, true); 64 | #endregion 65 | 66 | #region Multiple levels of Includes 67 | //Launch_date_unix and Static_fire_date_unix need custom converter 68 | spaceXContext.ContractResolver = new SpaceXContractResolver(); 69 | 70 | var launches = spaceXContext.Launches(null, 10, 0, null, null) 71 | .Include(launch => launch.Links) 72 | .Include(launch => launch.Rocket) 73 | .Include(launch => launch.Rocket.Second_stage.Payloads.Select(payload => payload.Manufacturer)) 74 | .ToList(); 75 | 76 | RenderLaunches(launches); 77 | #endregion 78 | } 79 | 80 | private static void RenderLaunches(List launches) 81 | { 82 | var table = new Table().Title("Launches"); 83 | table.AddColumn(nameof(Launch.Mission_name), column => column.Width = 12).AddColumn(nameof(Launch.Launch_date_utc), column => column.Width = 15) 84 | .AddColumn(nameof(Launch.Rocket.Rocket_name)).AddColumn(nameof(Launch.Links)).AddColumn( 85 | $"{nameof(Launch.Rocket.Second_stage.Payloads)} {nameof(Payload.Manufacturer)}", column => column.Width=12); 86 | 87 | foreach (var launch in launches) 88 | { 89 | var linksTable = new Table().AddColumn(nameof(launch.Links)); 90 | linksTable.AddRow(new Markup($"[link={launch.Links.Article_link}]Article_link - {launch.Links.Article_link}[/]")); 91 | linksTable.AddRow(new Markup($"[link={launch.Links.Video_link}]Video_link - {launch.Links.Video_link}[/]")); 92 | linksTable.AddRow(new Markup($"[link={launch.Links.Presskit}]Presskit - {launch.Links.Presskit}[/]")); 93 | linksTable.AddRow(new Markup($"[link={launch.Links.Reddit_launch}]Reddit_launch - {launch.Links.Reddit_launch}[/]")); 94 | linksTable.AddRow(new Markup($"[link={launch.Links.Wikipedia}]Wikipedia - {launch.Links.Wikipedia}[/]")); 95 | 96 | var payloadManufacturers = string.Join(Environment.NewLine, launch.Rocket.Second_stage.Payloads.Where(payload => payload != null) 97 | .Select(p => p.Manufacturer)); 98 | 99 | table.AddRow(new Markup(launch.Mission_name), 100 | new Markup(launch.Launch_date_utc.ToString()), 101 | new Markup(launch.Rocket.Rocket_name), 102 | linksTable, 103 | new Markup(payloadManufacturers)); 104 | } 105 | 106 | AnsiConsole.Render(table); 107 | AnsiConsole.MarkupLine(""); 108 | } 109 | 110 | private static void RenderMissions(List missions, bool showPayload = false) 111 | { 112 | var table = new Table().Title(showPayload ? "Missions with Payload" : "Missions"); 113 | 114 | table.AddColumn(nameof(Mission.Name)).AddColumn(nameof(Mission.Description)).AddColumn(nameof(Mission.Manufacturers)); 115 | 116 | if (showPayload) 117 | { 118 | table.AddColumn("Payloads"); 119 | } 120 | 121 | foreach (var mission in missions) 122 | { 123 | var manufacturers = string.Join(Environment.NewLine, mission.Manufacturers); 124 | 125 | var rowItems = new List { new Markup(mission.Name), new Markup(mission.Description), new Markup(manufacturers) }; 126 | 127 | if (showPayload) 128 | { 129 | var payloadsTable = new Table().AddColumn("Property").AddColumn("Value").Centered(); 130 | 131 | //For some reason the server returns null items in the list 132 | foreach (var payload in mission.Payloads.Where(payload => payload != null)) 133 | { 134 | payloadsTable.AddRow(nameof(payload.Nationality), payload.Nationality); 135 | payloadsTable.AddRow(nameof(payload.Payload_mass_kg), payload.Payload_mass_kg.ToString()); 136 | payloadsTable.AddRow(nameof(payload.Orbit), payload.Orbit); 137 | payloadsTable.AddRow(nameof(payload.Reused), payload.Reused.ToString()); 138 | 139 | payloadsTable.AddEmptyRow(); 140 | } 141 | 142 | rowItems.Add(payloadsTable); 143 | } 144 | 145 | table.AddRow(rowItems); 146 | } 147 | 148 | AnsiConsole.Render(table); 149 | AnsiConsole.MarkupLine(""); 150 | } 151 | 152 | private static void RenderCompanyDetails(Info company) 153 | { 154 | var table = new Table().Title("Company Details"); 155 | 156 | table.AddColumn("Property").AddColumn("Value").Centered(); 157 | 158 | table.AddRow(nameof(company.Name), company.Name); 159 | table.AddRow(nameof(company.Ceo), company.Ceo); 160 | table.AddRow(nameof(company.Summary), company.Summary); 161 | table.AddRow(nameof(company.Founded), company.Founded.ToString()); 162 | table.AddRow(nameof(company.Founder), company.Founder); 163 | table.AddRow(nameof(company.Employees), company.Employees.ToString()); 164 | 165 | AnsiConsole.Render(table); 166 | AnsiConsole.MarkupLine(""); 167 | } 168 | 169 | private static void RenderCompanyDetailsAndLinks(Info company) 170 | { 171 | var table = new Table().Title("Company Details and Headquarters"); 172 | 173 | table.AddColumn("Property").AddColumn("Value").Centered(); 174 | 175 | table.AddRow(nameof(company.Name), company.Name); 176 | table.AddRow(nameof(company.Ceo), company.Ceo); 177 | table.AddRow(nameof(company.Summary), company.Summary); 178 | table.AddRow(nameof(company.Founded), company.Founded.ToString()); 179 | table.AddRow(nameof(company.Founder), company.Founder); 180 | table.AddRow(nameof(company.Employees), company.Employees.ToString()); 181 | 182 | table.AddRow(new Markup(nameof(company.Headquarters)), 183 | new Panel(string.Join(Environment.NewLine, company.Headquarters.State, company.Headquarters.City, company.Headquarters.Address))); 184 | 185 | AnsiConsole.Render(table); 186 | 187 | AnsiConsole.MarkupLine($"[link={company.Links.Elon_twitter}]Elon Twitter - {company.Links.Elon_twitter}[/]"); 188 | AnsiConsole.MarkupLine($"[link={company.Links.Flickr}]Flickr - {company.Links.Flickr}[/]"); 189 | AnsiConsole.MarkupLine($"[link={company.Links.Twitter}]Twitter - {company.Links.Twitter}[/]"); 190 | AnsiConsole.MarkupLine($"[link={company.Links.Website}]Website - {company.Links.Website}[/]"); 191 | AnsiConsole.MarkupLine(""); 192 | } 193 | 194 | private static void RenderCompanySummary(CompanySummary companyInfo) 195 | { 196 | var table = new Table().Title("Company Selected Details and Headquarters"); 197 | 198 | table.AddColumn("Property").AddColumn("Value"); 199 | 200 | table.AddRow(nameof(companyInfo.Name), companyInfo.Name); 201 | table.AddRow(nameof(companyInfo.Ceo), companyInfo.Ceo); 202 | table.AddRow(new Markup(nameof(companyInfo.Headquarters)), 203 | new Panel(string.Join(Environment.NewLine, companyInfo.Headquarters.State, companyInfo.Headquarters.City, companyInfo.Headquarters.Address))); 204 | 205 | AnsiConsole.Render(table); 206 | AnsiConsole.MarkupLine(""); 207 | } 208 | } 209 | 210 | class CompanySummary 211 | { 212 | public string Ceo { get; set; } 213 | public string Name { get; set; } 214 | public AddressType Headquarters { get; set; } 215 | } 216 | 217 | public class SpaceXContractResolver : DefaultContractResolver 218 | { 219 | protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) 220 | { 221 | var property = base.CreateProperty(member, memberSerialization); 222 | 223 | var isDate = property.PropertyType == typeof(DateTime) || property.PropertyType == typeof(DateTime?); 224 | if (isDate && property.PropertyName.Contains("unix")) 225 | { 226 | property.Converter = new UnixDateTimeConverter(); 227 | } 228 | 229 | return property; 230 | } 231 | } 232 | } 233 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GraphQLinq 2 | 3 | LINQ to GraphQL - Strongly typed GraphQL queries with LINQ query syntax. 4 | 5 | [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=for-the-badge&logo=Apache)](License.md) 6 | [![AppVeyor](https://img.shields.io/appveyor/build/Giorgi/graphqlinq/master.svg?style=for-the-badge&logo=appveyor)](https://ci.appveyor.com/project/Giorgi/graphqlinq) 7 | [![Coverage Status](https://img.shields.io/coveralls/github/Giorgi/GraphQLinq?logo=coveralls&style=for-the-badge)](https://coveralls.io/github/Giorgi/graphqlinq) 8 | [![Ko-Fi](https://img.shields.io/static/v1?style=for-the-badge&message=Support%20the%20Project&color=success&logo=ko-fi&label=$$)](https://ko-fi.com/U6U81LHU8) 9 | 10 | 11 | [![](https://img.shields.io/nuget/dt/GraphQLinq.Client.svg?label=GraphQLinq.Client&style=for-the-badge&logo=NuGet)](https://www.nuget.org/packages/GraphQLinq.Client/) 12 | [![](https://img.shields.io/nuget/dt/GraphQLinq.Scaffolding.svg?label=GraphQLinq.Scaffolding&style=for-the-badge&logo=NuGet)](https://www.nuget.org/packages/GraphQLinq.Scaffolding/) 13 | 14 | ![Project Icon](docs/Images/Icon.png "GraphQLinq Project Icon") 15 | 16 | - [About The Project](#about-the-project) 17 | - [Getting Started](#getting-started) 18 | - [Installing Scaffolding Tool](#installing-scaffolding-tool) 19 | - [Scaffolding Client Code](#scaffolding-client-code) 20 | - [Install GraphQLinq NuGet Package](#install-graphqlinq-nuget-package) 21 | - [Running GraphQL Queries with LINQ](#running-graphql-queries-with-linq) 22 | - [Query all Primitive Properties of a Type](#query-all-primitive-properties-of-a-type) 23 | - [Query Specific Properties](#query-specific-properties) 24 | - [Include Navigation Properties](#include-navigation-properties) 25 | - [Pass Parameters to Queries and Compose Queries](#pass-parameters-to-queries-and-compose-queries) 26 | - [Include Multiple Levels of Navigation Properties](#include-multiple-levels-of-navigation-properties) 27 | - [View Generated Query](#view-generated-query) 28 | - [Roadmap](#roadmap) 29 | - [Contributing](#contributing) 30 | - [License](#license) 31 | 32 | ## About The Project 33 | 34 | GraphQLinq is a .NET tool for generating C# classes from a GraphQL endpoint and a .Net Standard library for writing strongly typed GraphQL queries with LINQ. 35 | 36 | With GraphQLinq you will: 37 | 38 | - Write strongly typed queries with LINQ. 39 | - Have your queries checked by the compiler. 40 | - Run queries and deserialize JSON response into strongly typed classes in a single method call. 41 | - View queries generated by LINQ to GraphQL. 42 | 43 | ## Getting Started 44 | 45 | ### Install Scaffolding Tool 46 | 47 | Before you starting writing queries, you need to generate classes from GraphQL types. This is done by `GraphQLinq.Scaffolding`, a .NET tool that is part of this project. 48 | 49 | To get the tool, open your favourite command shell and run 50 | 51 | ```sh 52 | dotnet tool install --global --version 1.0.0-beta GraphQLinq.Scaffolding 53 | ``` 54 | 55 | Running this command will install the `GraphQLinq.Scaffolding` tool and make it available globally for all projects. 56 | 57 | ### Scaffolding Client Code 58 | 59 | Next, navigate to the project where you want to add the classes and scaffold the client code. In this example, I will use the [SpaceX GraphQL Api](https://api.spacex.land/graphql) so run the following command: 60 | 61 | ```sh 62 | graphqlinq-scaffold https://api.spacex.land/graphql -o SpaceX -n SpaceX 63 | ``` 64 | 65 | The `o` option specifies the output directory for generated classes, and `n` specifies the namespace of the classes. 66 | 67 | ![Scaffolding](docs/Images/Scaffolding.gif "Scaffolding GraphQL Client") 68 | 69 | ### Install GraphQLinq NuGet Package 70 | 71 | Before writing the queries, you need to install the LINQ to GraphQL client library from NuGet. Run the following command to install it in the current project: 72 | 73 | ```sh 74 | dotnet add package GraphQLinq.Client --version 1.0.0-beta 75 | ``` 76 | 77 | ## Running GraphQL Queries with LINQ 78 | 79 | The scaffolding tool generates classes for types available in the GraphQL type system and a `QueryContext` class that serves as an entry point for running the queries. GraphQLinq supports running different kinds of queries. 80 | 81 | ### Query all Primitive Properties of a Type 82 | 83 | To query all properties of a type, simply run a query like this: 84 | 85 | ```cs 86 | var spaceXContext = new QueryContext(); 87 | 88 | var company = spaceXContext.Company().ToItem(); 89 | 90 | RenderCompanyDetails(company); 91 | ``` 92 | 93 | This will query all primitive and string properties of `Company`, but it won't query nested properties or collection type properties. Here is the output of the code snippet: 94 | 95 | ```sh 96 | ┌───────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────┐ 97 | │ Property │ Value │ 98 | ├───────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────┤ 99 | │ Name │ SpaceX │ 100 | │ Ceo │ Elon Musk │ 101 | │ Summary │ SpaceX designs, manufactures and launches advanced rockets and spacecraft. The company was founded in │ 102 | │ │ 2002 to revolutionize space technology, with the ultimate goal of enabling people to live on other │ 103 | │ │ planets. │ 104 | │ Founded │ 2002 │ 105 | │ Founder │ Elon Musk │ 106 | │ Employees │ 7000 │ 107 | └───────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────┘ 108 | ``` 109 | 110 | ### Query Specific Properties 111 | 112 | If you want to query specific properties, including a navigation property, you can specify it with the `Select` method. You either map the projection to an existing type or an anonymous object (`Headquarters` is a nested property): 113 | 114 | ```cs 115 | var companySummaryAnonymous = spaceXContext.Company().Select(c => new { c.Ceo, c.Name, c.Headquarters }).ToItem(); 116 | 117 | //Use data class to select specific properties 118 | var companySummary = spaceXContext.Company().Select(c => new CompanySummary 119 | { 120 | Ceo = c.Ceo, 121 | Name = c.Name, 122 | Headquarters = c.Headquarters 123 | }).ToItem(); 124 | 125 | RenderCompanySummary(companySummary); 126 | ``` 127 | 128 | This will result in the following output: 129 | 130 | ```sh 131 | ┌──────────────┬─────────────────┐ 132 | │ Property │ Value │ 133 | ├──────────────┼─────────────────┤ 134 | │ Name │ SpaceX │ 135 | │ Ceo │ Elon Musk │ 136 | │ Headquarters │ ┌─────────────┐ │ 137 | │ │ │ California │ │ 138 | │ │ │ Hawthorne │ │ 139 | │ │ │ Rocket Road │ │ 140 | │ │ └─────────────┘ │ 141 | └──────────────┴─────────────────┘ 142 | ``` 143 | 144 | ### Include Navigation Properties 145 | 146 | You can also query navigation properties using the `Include` method. You can include several properties if you need, and you can also `Include` nested navigation properties: 147 | 148 | ```cs 149 | var companyWithHeadquartersAndLinks = spaceXContext.Company() 150 | .Include(info => info.Headquarters) 151 | .Include(info => info.Links).ToItem(); 152 | 153 | RenderCompanyDetailsAndLinks(companyWithHeadquartersAndLinks); 154 | ``` 155 | 156 | ### Pass Parameters to Queries and Compose Queries 157 | 158 | If the query has parameters, the generated method will have a parameter for each query parameter. 159 | 160 | This code will query for all `Missions` that included **Orbital ATK** as a manufacturer. It also builds a new query over the existing one that 161 | includes `Payloads` in the result. 162 | 163 | ```cs 164 | var missionsQuery = spaceXContext.Missions(new MissionsFind { Manufacturer = "Orbital ATK" }, null, null) 165 | .Include(mission => mission.Manufacturers); 166 | var missions = missionsQuery.ToList(); 167 | 168 | RenderMissions(missions); 169 | 170 | var missionsWithPayloads = missionsQuery.Include(mission => mission.Payloads).ToList(); 171 | 172 | RenderMissions(missionsWithPayloads, true); 173 | ``` 174 | 175 | ### Include Multiple Levels of Navigation Properties 176 | 177 | The `Include` method allows quering for multi-level nested properties too. For example, here is how to query for `Launches` and include Rocket's second stage payload manufacturer: 178 | 179 | ```cs 180 | //Launch_date_unix and Static_fire_date_unix need custom converter 181 | spaceXContext.ContractResolver = new SpaceXContractResolver(); 182 | 183 | var launches = spaceXContext.Launches(null, 10, 0, null, null) 184 | .Include(launch => launch.Links) 185 | .Include(launch => launch.Rocket) 186 | .Include(launch => launch.Rocket.Second_stage.Payloads.Select(payload => payload.Manufacturer)) 187 | .ToList(); 188 | 189 | RenderLaunches(launches); 190 | ``` 191 | 192 | ### View Generated Query 193 | 194 | You can view the GraphQL query and variables by using the `Query` and `Variables` property of the `GraphQuery` class. The `ToString()` method of the `GraphQuery` class returns the query and the variables combined: 195 | 196 | ```cs 197 | var missionsQuery = spaceXContext.Missions(new MissionsFind { Manufacturer = "Orbital ATK" }, null, null) 198 | .Include(mission => mission.Manufacturers); 199 | 200 | var query = missionsQuery.Query; 201 | var fullQuery = missionsQuery.ToString(); 202 | ``` 203 | 204 | If you run the above code `query` will be equal to 205 | 206 | ```js 207 | query ($find: MissionsFind) { result: missions (find: $find) { 208 | description 209 | id 210 | name 211 | twitter 212 | website 213 | wikipedia 214 | manufacturers 215 | }} 216 | ``` 217 | 218 | and the content of `fullQuery` will be: 219 | 220 | ```json 221 | {"query":"query ($find: MissionsFind) { result: missions (find: $find) { 222 | description 223 | id 224 | name 225 | twitter 226 | website 227 | wikipedia 228 | manufacturers 229 | }}","variables":{"find":{"manufacturer":"Orbital ATK"}}} 230 | ``` 231 | 232 | ## Roadmap 233 | 234 | See the [open issues](https://github.com/Giorgi/GraphQLinq/issues) for a list of proposed features and known issues. 235 | 236 | ## Contributing 237 | 238 | If you encounter a bug or have a feature request, please use the [Issue Tracker](https://github.com/Giorgi/GraphQLinq/issues/new). The project is also open to contributions, so feel free to fork the project and open pull requests. 239 | 240 | ## License 241 | 242 | Copyright © Giorgi Dalakishvili 243 | 244 | Distributed under the Apache License. See [License](License.md) for more information. 245 | --------------------------------------------------------------------------------