prisma-archive / graphcool-lib

A convenient tool to use in Graphcool functions to make requests against your Graphcool API
33 stars 6 forks source link

Rename `fromEvent` to something more expressive #6

Open nikolasburk opened 7 years ago

nikolasburk commented 7 years ago

I think the fromEvent function should be renamed to something that expresses what it does. A few suggestions:

marktani commented 7 years ago

personally, I like fromEvent, it sounds like a builder function that takes an event, which it is. Maybe it could be more explicit like apiFromEvent? But I don't think it's necessary.

nikolasburk commented 7 years ago

But what does it build? the name doesn’t give any context on what the result of the function will be. I think the fact that it’s coming from an event would ideally be transported through the parameter name/type, smth like: api(event: Event). I think apiFromEvent(event: Event) might be a good compromise. Also, maybe I'm the only one who's confused by that naming? Would like to hear other people's opinions :)

kbrandwijk commented 7 years ago

apiFromEvent is wrong, because it returns the Graphcool object. .api(...) returns the api.

marktani commented 7 years ago

You're right, @kbrandwijk. Your point makes me think even more that the current terminology is fine. But yea, I'm open for a discussion here, too.

It should be noted that this would be a big breaking change for functions on the legacy function runtime (those were the latest version is resolved when updating an existing or creating a new function).

kbrandwijk commented 7 years ago

I think the naming is fine. As it's a factory function, it could have started with a capital, but other than that, and given the fact it's a breaking change, I wouldn't worry about it.

@nikolasburk to distract you from it, try running this query here :wink: :see_no_evil:

query { 
  repository(owner:"graphcool", name:"graphcool") { 
    issues(states:OPEN) {
      totalCount
    }
  }
}