mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-18 00:10:32 +00:00
split query resolvers into separate files
This commit is contained in:
20
src/resolvers/QueryResolvers.ts
Normal file
20
src/resolvers/QueryResolvers.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { ServerContext } from "../ServerContext";
|
||||
import { Resolvers } from "../generated/graphql";
|
||||
|
||||
export const QueryResolvers: Resolvers<ServerContext> = {
|
||||
Query: {
|
||||
systems: async (parent, args, contextValue, info) => {
|
||||
return await contextValue.repository.getSystems();
|
||||
},
|
||||
system: async (parent, args, contextValue, info) => {
|
||||
if (!args.id) return null;
|
||||
const system = await contextValue.repository.getSystemById(args.id);
|
||||
if (system === null) return null;
|
||||
|
||||
return {
|
||||
name: system.name,
|
||||
id: system.id,
|
||||
};
|
||||
}
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user