graphile / graphile/crystal

Make constructors protected/private and add static constructor methods (of/from/with)

Open
#1,819 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
12.9k
Forks
625
Avg merge
5h 23m
Merged PRs (30d)
24

Description

### Feature description

As discussed on Discord, the classes of `PgSelectSingle`, `PgSelect` etc. are not supposed to be used for anything except `instanceof` checks. I propose we make it impossible to construct them using `new`.

This means the constructor should either be `protected` or `private`, and each class will require an additional static method to construct said class.

Open questions:

* What should the name of the factory method be on each class? (`PgSelect.from`, `PgSelect.with`, `PgSelect.of`, etc.)
* Should the constructors be `private` or `protected`?
* Which classes does this apply?

### Supporting development

I [tick all that apply]:

- [ ] am interested in building this feature myself
- [ ] am interested in collaborating on building this feature
- [ ] am willing to help testing this feature before it's released
- [ ] am willing to write a test-driven test suite for this feature (before it exists)
- [ ] am a [Graphile sponsor](https://www.graphile.org/sponsor/) ❤️
- [ ] have an active [support or consultancy contract](https://www.graphile.org/support/) with Graphile

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.