Comments (6)
@vilmibm Thanks for the feedback!
I like the idea of including a DefaultRESTClient
and DefaultGQLClient
that will auto-resolve host
and token
. I don't think we would want to auto-resolve the remote as part of the client instantiation, just because the remote doesn't necessarily need to be resolved depending on the API endpoint being hit. I think it would be more useful to have a function called CurrentRepo
that would do the resolving. In fact I am wondering if we should even expose the rest of the packages? @mislav mentioned offline that his main feedback would be to reduce the surface area exposed so we have less to maintain.
After thinking about it a bit more I wonder if we could get away with exposing only four functions in this module.
gh.Exec(args)
-- to execute some gh
command and return results
gh.DefaultRESTClient(opts)
-- REST API client that auto-resolves host
and token
gh.DefaultGQLClient(opts)
-- GQL API client that auto-resolves host
and token
gh.CurrentRepo()
-- Resolves remotes to a current repository
This would mean moving config
, git
, auth
packages to internal
so that they can't be imported. I envision the api
package still having some exposed pieces to give some basic configuration for the API clients.
What do you think?
from go-gh.
Makes sense re: remotes and I like the gh.CurrentRepo()
idea to start with.
For now, I'm definitely in favor of a consolidation like this. I'd like us to expose loading config since I'd like extensions to be able to store config stanzas, but I'm comfortable saving that for a future improvement as we might want to do more up front design on that interface.
Is the idea that the clients would resolve the token based on a provided host?
from go-gh.
Yeah that was what I was thinking. The client initializer options would allow specifying host and/or token, and if they are provided then skip the auto-resolving step for either.
from go-gh.
👍 maybe we don't need to call them Default
then?
from go-gh.
@vilmibm That makes sense. I made the changes if you would like to take another look.
from go-gh.
@vilmibm Going to close this issue out as I think I have addressed all the feedback here. Let me know if you think otherwise.
from go-gh.
Related Issues (20)
- GQLCLient should return GQLError for query and mutation methods
- Add a GraphQL Mutation with an `input` object to examples HOT 1
- Add pagination examples
- jsonpretty should not add new lines if not indenting
- TokenForHost "authentication token not found" message could be more informative HOT 3
- Feature Request: Add support to call the `gh` command interactively HOT 3
- RestClient no longer returns an HTTPError HOT 2
- Expose `ghLookupPath` or a better way to run `gh` HOT 3
- Issue while using from remote connection HOT 6
- `asciisanitizer.Sanitizer` mishandled the `�` unicode character HOT 1
- Add the ability to introduce repository specific configurations for gh-cli and its extensions HOT 2
- Create CODEOWNERS file ensuring the cli/code-reviewers are assigned to PRs
- CVE Vulnerability CVE-2023-3978 in dependency HOT 1
- hyperlink truncated at end of row isn't closed correctly HOT 2
- Use retryable HTTP client (for 50x) errors
- Allow default host to be determined based on configuration preference HOT 5
- Rest client support for endpoint not returning a JSON HOT 3
- AlecAivazis/survey is archived HOT 3
- Support passing httptest URLs in api.ClientOptions HOT 1
- [pkg/cmd/root/root.go](url) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-gh.