mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-16 23:40:32 +00:00
initial commit
This commit is contained in:
13
.gitignore
vendored
Normal file
13
.gitignore
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/src/generated
|
||||||
|
|
||||||
|
/tmp
|
||||||
|
/out-tsc
|
||||||
|
|
||||||
|
/node_modules
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
/.pnp
|
||||||
|
.pnp.js
|
||||||
|
|
||||||
|
.vscode/*
|
||||||
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||||
|
</state>
|
||||||
|
</component>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/project-inter-server.iml" filepath="$PROJECT_DIR$/.idea/project-inter-server.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
12
.idea/project-inter-server.iml
generated
Normal file
12
.idea/project-inter-server.iml
generated
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
14
codegen.ts
Normal file
14
codegen.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
import type { CodegenConfig } from '@graphql-codegen/cli';
|
||||||
|
|
||||||
|
const config: CodegenConfig = {
|
||||||
|
overwrite: true,
|
||||||
|
schema: "./schema.graphql",
|
||||||
|
generates: {
|
||||||
|
"src/generated/graphql.ts": {
|
||||||
|
plugins: ["typescript", "typescript-resolvers"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
2
dist/generated/graphql.js
vendored
Normal file
2
dist/generated/graphql.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
34
dist/index.js
vendored
Normal file
34
dist/index.js
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
"use strict";
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const fs_1 = require("fs");
|
||||||
|
const server_1 = require("@apollo/server");
|
||||||
|
const standalone_1 = require("@apollo/server/standalone");
|
||||||
|
const resolvers_1 = require("./resolvers");
|
||||||
|
const typeDefs = (0, fs_1.readFileSync)("./schema.graphql", "utf8");
|
||||||
|
function main() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const server = new server_1.ApolloServer({
|
||||||
|
typeDefs,
|
||||||
|
resolvers: resolvers_1.resolvers
|
||||||
|
});
|
||||||
|
const { url } = yield (0, standalone_1.startStandaloneServer)(server, {
|
||||||
|
listen: {
|
||||||
|
port: 4000,
|
||||||
|
},
|
||||||
|
context: (_a) => __awaiter(this, [_a], void 0, function* ({ req, res }) {
|
||||||
|
return {};
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
console.log(`Server ready at: ${url}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
main();
|
||||||
168
dist/resolvers.js
vendored
Normal file
168
dist/resolvers.js
vendored
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.resolvers = void 0;
|
||||||
|
// Mock data
|
||||||
|
const systems = [
|
||||||
|
{
|
||||||
|
id: "1",
|
||||||
|
name: "Chapman University",
|
||||||
|
routes: [],
|
||||||
|
stops: [],
|
||||||
|
shuttles: [],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const routes = [
|
||||||
|
{
|
||||||
|
name: "Red Route",
|
||||||
|
id: "1",
|
||||||
|
system: systems[0],
|
||||||
|
orderedStops: [],
|
||||||
|
shuttles: [],
|
||||||
|
polylineCoordinates: [],
|
||||||
|
color: "#ffffff",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Teal Route",
|
||||||
|
id: "2",
|
||||||
|
system: systems[0],
|
||||||
|
orderedStops: [],
|
||||||
|
shuttles: [],
|
||||||
|
polylineCoordinates: [],
|
||||||
|
color: "#ffffff",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const stops = [
|
||||||
|
{
|
||||||
|
id: "1",
|
||||||
|
name: "Chapman Court",
|
||||||
|
coordinates: {
|
||||||
|
latitude: 33.796001,
|
||||||
|
longitude: -117.8892805,
|
||||||
|
},
|
||||||
|
system: systems[0],
|
||||||
|
etas: [],
|
||||||
|
orderedStops: [],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "2",
|
||||||
|
name: "Chapman Grand",
|
||||||
|
coordinates: {
|
||||||
|
latitude: 33.804433,
|
||||||
|
longitude: -117.895966,
|
||||||
|
},
|
||||||
|
system: systems[0],
|
||||||
|
etas: [],
|
||||||
|
orderedStops: [],
|
||||||
|
}
|
||||||
|
];
|
||||||
|
const orderedStopsForRedRoute = [
|
||||||
|
{
|
||||||
|
route: routes[0],
|
||||||
|
stop: stops[0],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
route: routes[0],
|
||||||
|
stop: stops[1],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const orderedStopsForTealRoute = [
|
||||||
|
{
|
||||||
|
route: routes[1],
|
||||||
|
stop: stops[1],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
route: routes[1],
|
||||||
|
stop: stops[0],
|
||||||
|
}
|
||||||
|
];
|
||||||
|
orderedStopsForRedRoute[0].nextStop = orderedStopsForRedRoute[1];
|
||||||
|
orderedStopsForRedRoute[1].previousStop = orderedStopsForRedRoute[0];
|
||||||
|
orderedStopsForTealRoute[0].nextStop = orderedStopsForTealRoute[1];
|
||||||
|
orderedStopsForTealRoute[1].previousStop = orderedStopsForTealRoute[0];
|
||||||
|
stops[0].orderedStops = [orderedStopsForRedRoute[0], orderedStopsForTealRoute[1]];
|
||||||
|
stops[1].orderedStops = [orderedStopsForRedRoute[1], orderedStopsForTealRoute[0]];
|
||||||
|
routes[0].orderedStops = orderedStopsForRedRoute;
|
||||||
|
routes[1].orderedStops = orderedStopsForTealRoute;
|
||||||
|
const shuttles = [
|
||||||
|
{
|
||||||
|
name: "Red Shuttle 17",
|
||||||
|
id: "1",
|
||||||
|
coordinates: {
|
||||||
|
latitude: 33.796001,
|
||||||
|
longitude: -117.8892805,
|
||||||
|
},
|
||||||
|
route: routes[0],
|
||||||
|
system: systems[0],
|
||||||
|
etas: [],
|
||||||
|
}
|
||||||
|
];
|
||||||
|
const etas = [
|
||||||
|
{
|
||||||
|
stop: stops[0],
|
||||||
|
shuttle: shuttles[0],
|
||||||
|
secondsRemaining: 12.023,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
stop: stops[1],
|
||||||
|
shuttle: shuttles[0],
|
||||||
|
secondsRemaining: 600.123,
|
||||||
|
}
|
||||||
|
];
|
||||||
|
shuttles[0].etas = etas;
|
||||||
|
routes[0].shuttles = shuttles;
|
||||||
|
systems[0].stops = stops;
|
||||||
|
systems[0].routes = routes;
|
||||||
|
systems[0].shuttles = shuttles;
|
||||||
|
exports.resolvers = {
|
||||||
|
Query: {
|
||||||
|
systems: () => systems,
|
||||||
|
system: (parent, args, contextValue, info) => {
|
||||||
|
const system = systems.find((system) => system.id === args.id);
|
||||||
|
if (!system) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return system;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
System: {
|
||||||
|
stop: (parent, args, contextValue, info) => {
|
||||||
|
const stop = stops.find((stop) => stop.id === args.id);
|
||||||
|
if (!stop) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return stop;
|
||||||
|
},
|
||||||
|
route: (parent, args, contextValue, info) => {
|
||||||
|
const route = routes.find((route) => route.id === args.id);
|
||||||
|
if (!route) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return route;
|
||||||
|
},
|
||||||
|
shuttle: (parent, args, contextValue, info) => {
|
||||||
|
const shuttle = shuttles.find((shuttle) => shuttle.id === args.id);
|
||||||
|
if (!shuttle) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return shuttle;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Route: {
|
||||||
|
nextOrderedStop: (parent, args, contextValue, info) => {
|
||||||
|
const orderedStop = parent.orderedStops.find((orderedStop) => orderedStop.stop.id === args.forStopId);
|
||||||
|
if (!orderedStop || !orderedStop.nextStop) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return orderedStop.nextStop;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Shuttle: {
|
||||||
|
eta: (parent, args, contextValue, info) => {
|
||||||
|
const etaForNextStop = parent.etas.find((eta) => eta.stop.id === args.forStopId);
|
||||||
|
if (!etaForNextStop) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return etaForNextStop;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
6726
package-lock.json
generated
Normal file
6726
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
23
package.json
Normal file
23
package.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"name": "project-inter-server",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "dist/index.js",
|
||||||
|
"scripts": {
|
||||||
|
"compile": "npm run generate && tsc",
|
||||||
|
"start": "npm run compile && node ./dist/index.js",
|
||||||
|
"generate": "graphql-codegen --config codegen.ts"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@graphql-codegen/cli": "5.0.3",
|
||||||
|
"@graphql-codegen/typescript": "4.1.2",
|
||||||
|
"@graphql-codegen/typescript-resolvers": "4.4.1",
|
||||||
|
"@types/node": "^22.10.2",
|
||||||
|
"typescript": "^5.7.2"
|
||||||
|
},
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@apollo/server": "^4.11.2",
|
||||||
|
"graphql": "^16.10.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
63
schema.graphql
Normal file
63
schema.graphql
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
type Query {
|
||||||
|
systems: [System!]!
|
||||||
|
system(id: ID): System
|
||||||
|
}
|
||||||
|
|
||||||
|
type System {
|
||||||
|
id: ID!
|
||||||
|
name: String!
|
||||||
|
routes: [Route!]!
|
||||||
|
route(id: ID): Route
|
||||||
|
stops: [Stop!]!
|
||||||
|
stop(id: ID): Stop
|
||||||
|
shuttles: [Shuttle!]!
|
||||||
|
shuttle(id: ID): Shuttle
|
||||||
|
}
|
||||||
|
|
||||||
|
type Route {
|
||||||
|
name: String!
|
||||||
|
id: ID!
|
||||||
|
system: System!
|
||||||
|
orderedStops: [OrderedStop!]!
|
||||||
|
nextOrderedStop(forStopId: ID): OrderedStop
|
||||||
|
shuttles: [Shuttle!]!
|
||||||
|
polylineCoordinates: [Coordinates!]!
|
||||||
|
color: String!
|
||||||
|
}
|
||||||
|
|
||||||
|
type OrderedStop {
|
||||||
|
nextStop: OrderedStop
|
||||||
|
previousStop: OrderedStop
|
||||||
|
route: Route!
|
||||||
|
stop: Stop!
|
||||||
|
}
|
||||||
|
|
||||||
|
type Stop {
|
||||||
|
id: ID!
|
||||||
|
name: String!
|
||||||
|
coordinates: Coordinates!
|
||||||
|
system: System!
|
||||||
|
etas: [ETA!]!
|
||||||
|
orderedStops: [OrderedStop!]!
|
||||||
|
}
|
||||||
|
|
||||||
|
type Coordinates {
|
||||||
|
latitude: Float!
|
||||||
|
longitude: Float!
|
||||||
|
}
|
||||||
|
|
||||||
|
type ETA {
|
||||||
|
stop: Stop!
|
||||||
|
shuttle: Shuttle!
|
||||||
|
secondsRemaining: Float!
|
||||||
|
}
|
||||||
|
|
||||||
|
type Shuttle {
|
||||||
|
name: String!
|
||||||
|
id: ID!,
|
||||||
|
coordinates: Coordinates!
|
||||||
|
route: Route!
|
||||||
|
system: System!
|
||||||
|
etas: [ETA!]!
|
||||||
|
eta(forStopId: ID): ETA
|
||||||
|
}
|
||||||
30
src/index.ts
Normal file
30
src/index.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import { readFileSync } from "fs";
|
||||||
|
import { ApolloServer } from "@apollo/server";
|
||||||
|
import { startStandaloneServer } from "@apollo/server/standalone";
|
||||||
|
import { resolvers } from "./resolvers";
|
||||||
|
|
||||||
|
const typeDefs = readFileSync("./schema.graphql", "utf8");
|
||||||
|
|
||||||
|
interface ServerContext {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const server = new ApolloServer<ServerContext>({
|
||||||
|
typeDefs,
|
||||||
|
resolvers
|
||||||
|
});
|
||||||
|
|
||||||
|
const { url } = await startStandaloneServer(server, {
|
||||||
|
listen: {
|
||||||
|
port: 4000,
|
||||||
|
},
|
||||||
|
context: async ({ req, res }) => {
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(`Server ready at: ${url}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
185
src/resolvers.ts
Normal file
185
src/resolvers.ts
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
import { Eta, OrderedStop, Resolvers, Route, Shuttle, Stop, System } from "./generated/graphql";
|
||||||
|
|
||||||
|
// Mock data
|
||||||
|
const systems: System[] = [
|
||||||
|
{
|
||||||
|
id: "1",
|
||||||
|
name: "Chapman University",
|
||||||
|
routes: [],
|
||||||
|
stops: [],
|
||||||
|
shuttles: [],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const routes: Route[] = [
|
||||||
|
{
|
||||||
|
name: "Red Route",
|
||||||
|
id: "1",
|
||||||
|
system: systems[0],
|
||||||
|
orderedStops: [],
|
||||||
|
shuttles: [],
|
||||||
|
polylineCoordinates: [],
|
||||||
|
color: "#ffffff",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Teal Route",
|
||||||
|
id: "2",
|
||||||
|
system: systems[0],
|
||||||
|
orderedStops: [],
|
||||||
|
shuttles: [],
|
||||||
|
polylineCoordinates: [],
|
||||||
|
color: "#ffffff",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const stops: Stop[] = [
|
||||||
|
{
|
||||||
|
id: "1",
|
||||||
|
name: "Chapman Court",
|
||||||
|
coordinates: {
|
||||||
|
latitude: 33.796001,
|
||||||
|
longitude: -117.8892805,
|
||||||
|
},
|
||||||
|
system: systems[0],
|
||||||
|
etas: [],
|
||||||
|
orderedStops: [],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "2",
|
||||||
|
name: "Chapman Grand",
|
||||||
|
coordinates: {
|
||||||
|
latitude: 33.804433,
|
||||||
|
longitude: -117.895966,
|
||||||
|
},
|
||||||
|
system: systems[0],
|
||||||
|
etas: [],
|
||||||
|
orderedStops: [],
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
const orderedStopsForRedRoute: OrderedStop[] = [
|
||||||
|
{
|
||||||
|
route: routes[0],
|
||||||
|
stop: stops[0],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
route: routes[0],
|
||||||
|
stop: stops[1],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const orderedStopsForTealRoute: OrderedStop[] = [
|
||||||
|
{
|
||||||
|
route: routes[1],
|
||||||
|
stop: stops[1],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
route: routes[1],
|
||||||
|
stop: stops[0],
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
orderedStopsForRedRoute[0].nextStop = orderedStopsForRedRoute[1];
|
||||||
|
orderedStopsForRedRoute[1].previousStop = orderedStopsForRedRoute[0];
|
||||||
|
orderedStopsForTealRoute[0].nextStop = orderedStopsForTealRoute[1];
|
||||||
|
orderedStopsForTealRoute[1].previousStop = orderedStopsForTealRoute[0];
|
||||||
|
|
||||||
|
stops[0].orderedStops = [orderedStopsForRedRoute[0], orderedStopsForTealRoute[1]];
|
||||||
|
stops[1].orderedStops = [orderedStopsForRedRoute[1], orderedStopsForTealRoute[0]];
|
||||||
|
routes[0].orderedStops = orderedStopsForRedRoute;
|
||||||
|
routes[1].orderedStops = orderedStopsForTealRoute;
|
||||||
|
|
||||||
|
const shuttles: Shuttle[] = [
|
||||||
|
{
|
||||||
|
name: "Red Shuttle 17",
|
||||||
|
id: "1",
|
||||||
|
coordinates: {
|
||||||
|
latitude: 33.796001,
|
||||||
|
longitude: -117.8892805,
|
||||||
|
},
|
||||||
|
route: routes[0],
|
||||||
|
system: systems[0],
|
||||||
|
etas: [],
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
const etas: Eta[] = [
|
||||||
|
{
|
||||||
|
stop: stops[0],
|
||||||
|
shuttle: shuttles[0],
|
||||||
|
secondsRemaining: 12.023,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
stop: stops[1],
|
||||||
|
shuttle: shuttles[0],
|
||||||
|
secondsRemaining: 600.123,
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
shuttles[0].etas = etas;
|
||||||
|
|
||||||
|
routes[0].shuttles = shuttles;
|
||||||
|
|
||||||
|
systems[0].stops = stops;
|
||||||
|
systems[0].routes = routes;
|
||||||
|
systems[0].shuttles = shuttles;
|
||||||
|
|
||||||
|
export const resolvers: Resolvers = {
|
||||||
|
Query: {
|
||||||
|
systems: () => systems,
|
||||||
|
system: (parent, args, contextValue, info) => {
|
||||||
|
const system = systems.find((system) => system.id === args.id);
|
||||||
|
if (!system) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return system;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
System: {
|
||||||
|
stop: (parent, args, contextValue, info) => {
|
||||||
|
const stop = stops.find((stop) => stop.id === args.id);
|
||||||
|
if (!stop) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return stop;
|
||||||
|
},
|
||||||
|
route: (parent, args, contextValue, info) => {
|
||||||
|
const route = routes.find((route) => route.id === args.id);
|
||||||
|
if (!route) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return route;
|
||||||
|
},
|
||||||
|
shuttle: (parent, args, contextValue, info) => {
|
||||||
|
const shuttle = shuttles.find((shuttle) => shuttle.id === args.id);
|
||||||
|
if (!shuttle) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return shuttle;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Route: {
|
||||||
|
nextOrderedStop: (parent, args, contextValue, info) => {
|
||||||
|
const orderedStop = parent.orderedStops.find((orderedStop) => orderedStop.stop.id === args.forStopId);
|
||||||
|
if (!orderedStop || !orderedStop.nextStop) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return orderedStop.nextStop;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Shuttle: {
|
||||||
|
eta: (parent, args, contextValue, info) => {
|
||||||
|
const etaForNextStop = parent.etas.find((eta) => eta.stop.id === args.forStopId);
|
||||||
|
if (!etaForNextStop) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return etaForNextStop;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
12
tsconfig.json
Normal file
12
tsconfig.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es2016",
|
||||||
|
"module": "commonjs",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"strict": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"outDir": "dist"
|
||||||
|
},
|
||||||
|
"include": ["src"]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user