28 lines
510 B
TypeScript
28 lines
510 B
TypeScript
import App from '../../models/app';
|
|
import Context from '../../types/express/context';
|
|
|
|
type Params = {
|
|
key: string;
|
|
};
|
|
|
|
const getAppConnections = async (
|
|
_parent: unknown,
|
|
params: Params,
|
|
context: Context
|
|
) => {
|
|
const app = App.findOneByKey(params.key);
|
|
|
|
const connections = await context.currentUser
|
|
.$relatedQuery('connections')
|
|
.where({
|
|
key: params.key,
|
|
});
|
|
|
|
return connections.map((connection) => ({
|
|
...connection,
|
|
app,
|
|
}));
|
|
};
|
|
|
|
export default getAppConnections;
|