graphcool-lib icon indicating copy to clipboard operation
graphcool-lib copied to clipboard

Rename `fromEvent` to something more expressive

Open nikolasburk opened this issue 8 years ago • 5 comments

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

  • graphcoolProjectContext (or getGraphcoolProjectContext)
  • graphcoolProject (or getGraphcoolProject)
  • graphcoolAPI (or getGraphcoolAPI)
  • ...

nikolasburk avatar Sep 21 '17 13:09 nikolasburk

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.

marktani avatar Oct 13 '17 16:10 marktani

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 :)

nikolasburk avatar Oct 13 '17 16:10 nikolasburk

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

kbrandwijk avatar Oct 13 '17 16:10 kbrandwijk

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).

marktani avatar Oct 13 '17 16:10 marktani

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
    }
  }
}

kbrandwijk avatar Oct 13 '17 17:10 kbrandwijk