I'm trying to figure out if I need to add static to a private method within my class for an Apollo/GraphQl app. Thanks in advance!
export const example: Resolvers = {
Query: {
Example: async(_parent, {
date
}) => {
return ExampleService.getExample(date);
}
},
};
class ExampleService {
getExample(date: string) {
const example = this.getExampleString();
return example;
}
// HERE: do I need static, in general, or is this class already a singleton???
private static getExampleString(): string {
return 'Example!';
}
}
// Side note: seems this is an anti-pattern according to the link provided below.
export default new ExampleService();
differences-between-creating-a-new-class-to-using-export-const