-
Notifications
You must be signed in to change notification settings - Fork 282
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
feat: add WithHeader
& WithCookie
#48
base: main
Are you sure you want to change the base?
Conversation
Will this be merged in anytime soon? Would be specifically useful for authorization. |
@IamFlowZ you can try my fork |
query.go
Outdated
@@ -70,7 +70,7 @@ func writeArgumentType(w io.Writer, t reflect.Type, value bool) { | |||
default: | |||
// Named type. E.g., "Int". | |||
name := t.Name() | |||
if name == "string" { // HACK: Workaround for https://github.com/shurcooL/githubv4/issues/12. | |||
if name == "string" { // HACK: Workaround for https://github.com/shurcooL/githubv4/issues/12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you @Laisky not include unnecessary changes like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
} | ||
|
||
// NewClient creates a GraphQL client targeting the specified GraphQL server URL. | ||
// If httpClient is nil, then http.DefaultClient is used. | ||
func NewClient(url string, httpClient *http.Client) *Client { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing a function's signature is a very bad idea for backward compatibility. It's better to create a new function and have the old call the new. A blog entry from the Go team discusses this here: https://blog.golang.org/module-compatibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just add some option args, not change the function's behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, you changed the function's signature. By adding args to the function, you broke backward compatibility. See the blog post from the Go team that I linked in the original message. You should never change a function's signature in a module unless you're doing a major version release with breaking changes, and even then, try to avoid it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you broke backward compatibility
it not broke the backward compatibility. I add option args, you can just ignore these args.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change here is to add a variadic, old implementations will not break. How is this a breaking change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Laisky, again, you changed the function's signature. Please see the provided reference on how it is a breaking change. The blog post from the Go team explains how it's a breaking change when you add args to an exported function. From the provided link "Often, breaking changes come in the form of new arguments to a function." https://blog.golang.org/module-compatibility they also cover how to add arguments to an exported function without making it a breaking change. Don't change a function's signature if you don't need to..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I add an new method called NewClientWithOptions
5d5da9b
to
52aa802
Compare
This is a great feature, but I would also prefer it if these were on a new method like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great feature, but I would also prefer it if these were on a new method like
NewClientWithOptions
or something.
good idea
} | ||
|
||
// NewClient creates a GraphQL client targeting the specified GraphQL server URL. | ||
// If httpClient is nil, then http.DefaultClient is used. | ||
func NewClient(url string, httpClient *http.Client) *Client { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I add an new method called NewClientWithOptions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I had a minor suggestion. (also, I'm not a maintainer, but would love to see this merged)
Co-authored-by: Steve Coffman <[email protected]>
Not a 1:1 replacement, but #73 might also enable this use case |
When is this going to be merged? |
will this be merged ? |
can set http client's headers and cookies
fully backwards-compatible.