Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename 'MaybePromise' to 'PromiseOrValue' #1798

Merged
merged 1 commit into from Mar 22, 2019

Conversation

IvanGoncharov
Copy link
Member

Suggested by @martijnwalraven
MaybePromise name confuses users into thinking: execute/graphql returns either Promise or null/undefined.
Also in our codebase, we frequently use [Mm]aybe* to represent optional things,
e.g.:

function isNode(maybeNode): boolean %checks {

function join(maybeArray, separator) {

Suggested by @martijnwalraven
`MaybePromise` name confuses users into thinking: `execute`/`graphql` returns
either Promise or null/undefined.
Also in our codebase we use `[Mm]aybe*` to represent optional things,
e.g.:
https://github.com/graphql/graphql-js/blob/8c96dc8276f2de27b8af9ffbd71a4597d483523f/src/language/visitor.js#L353
https://github.com/graphql/graphql-js/blob/8c96dc8276f2de27b8af9ffbd71a4597d483523f/src/language/printer.js#L244
@IvanGoncharov
Copy link
Member Author

@Cito What do you think? Maybe you have a better naming proposal?

@IvanGoncharov IvanGoncharov added the PR: polish 💅 PR doesn't change public API or any observed behaviour label Mar 22, 2019
@IvanGoncharov
Copy link
Member Author

Note: not breaking change, since it's part of jsutils:
https://github.com/graphql/graphql-js/blob/master/src/jsutils/README.md

These functions are not part of the module interface and are subject to change.

@Cito
Copy link
Member

Cito commented Mar 22, 2019

The name MaybePromise is also used by others, but @martijnwalraven has a point when he says Maybe already means "or null/undefined" in GraphQL.js elsewhere, and Flow also has the concept of Maybe Types for optional values. PromiseOrValue sounds good to me. I found that name also in the typescript definition for Promise.all(). So renaming maybe (pun intended) makes sense.

Copy link
Contributor

@mjmahone mjmahone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a solid clarity win to me, so I'm all for it.

@IvanGoncharov
Copy link
Member Author

Maybe already means "or null/undefined" in GraphQL.js elsewhere, and Flow also has the concept of Maybe Types for optional values. PromiseOrValue sounds good to me. I found that name also in the typescript definition for Promise.all().

Thanks for research 👍
I think naming is important for graphql-js as the reference implementation since readability is one of the top priorities.

@IvanGoncharov IvanGoncharov merged commit 329f357 into graphql:master Mar 22, 2019
@IvanGoncharov IvanGoncharov deleted the PromiseOrValue branch March 23, 2019 16:37
martijnwalraven added a commit to apollographql/DefinitelyTyped that referenced this pull request Mar 27, 2019
rbuckton pushed a commit to DefinitelyTyped/DefinitelyTyped that referenced this pull request Mar 29, 2019
* Add Martijn Walraven  to "Definitions by" section of the package header

* Add `validateSDL` function

* Add `toConfig` methods

See graphql/graphql-js#1331

* Add missing typing for `print` function

See graphql/graphql-js#1702

* Rename `MaybePromise` to `PromiseOrValue`

graphql/graphql-js#1798

* Rename `blockStringValue.js` to `blockString.js`, and `blockStringValue` to `dedentBlockStringValue`

See graphql/graphql-js@16afd2e and graphql/graphql-js@60a2bf8

* Update `graphql` version to 14.2

* Add `.prettierrc` and reformat all files

This adds a `.prettierrc` based on the defaults used in #24552 (comment), and reformats all files (only a few are affected).

* Fix `GraphQLSchema.toConfig()`

* Remove `.prettierrc`
alesn pushed a commit to alesn/DefinitelyTyped that referenced this pull request Apr 23, 2019
* Add Martijn Walraven  to "Definitions by" section of the package header

* Add `validateSDL` function

* Add `toConfig` methods

See graphql/graphql-js#1331

* Add missing typing for `print` function

See graphql/graphql-js#1702

* Rename `MaybePromise` to `PromiseOrValue`

graphql/graphql-js#1798

* Rename `blockStringValue.js` to `blockString.js`, and `blockStringValue` to `dedentBlockStringValue`

See graphql/graphql-js@16afd2e and graphql/graphql-js@60a2bf8

* Update `graphql` version to 14.2

* Add `.prettierrc` and reformat all files

This adds a `.prettierrc` based on the defaults used in DefinitelyTyped#24552 (comment), and reformats all files (only a few are affected).

* Fix `GraphQLSchema.toConfig()`

* Remove `.prettierrc`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: polish 💅 PR doesn't change public API or any observed behaviour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants