Luke

@perpetual_dev

Luke

@perpetual_dev

How are we organizing resolvers in backend graphQL? Right now I have a monster file called schema.js that is full of different types of Queries and mutations.

js
const resolvers = {  Query: {    getUserByID: async (parent, args, contextValue) => {      if (!contextValue.user) return;      return simpleResolver(        contextValue.pool,        'SELECT * FROM "user" WHERE id = $1;',        [contextValue.user.userId]      );    },  }}
2023-11-03T02:40:05.880Z
2
1
Greg
2023-11-07T20:53:56.723Z

I havent used graphql for a while mainly due to the amount of overhead of setting up a graphql server vs just using rest. But there are a few good articles that describe best practices for organizing resolvers.

Greg
2023-11-07T20:54:10.602Z
Luke

@perpetual_dev

How are we organizing resolvers in backend graphQL? Right now I have a monster file called schema.js that is full of different types of Queries and mutations.

js
const resolvers = {  Query: {    getUserByID: async (parent, args, contextValue) => {      if (!contextValue.user) return;      return simpleResolver(        contextValue.pool,        'SELECT * FROM "user" WHERE id = $1;',        [contextValue.user.userId]      );    },  }}
2023-11-03T02:40:05.880Z
1
Greg
2023-11-07T20:53:56.723Z

I havent used graphql for a while mainly due to the amount of overhead of setting up a graphql server vs just using rest. But there are a few good articles that describe best practices for organizing resolvers.

Greg
2023-11-07T20:54:10.602Z