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

Fix introspect options not ready for use immediately #34

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.18.x
go-version: 1.21.x
- name: Lint
run: go vet ./...

Expand All @@ -28,7 +28,10 @@ jobs:
- 1.15.x
- 1.16.x
- 1.17.x
- ^1.18 # Latest version of Go
- 1.18.x
- 1.19.x
- 1.20.x
- ^1.21 # Latest version of Go
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
Expand Down
22 changes: 9 additions & 13 deletions introspection.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,23 @@ func mergeIntrospectOptions(opts ...*IntrospectOptions) *IntrospectOptions {
// IntrospectWithMiddlewares returns an instance of graphql.IntrospectOptions with given middlewares
// to be pass to an instance of a graphql.Queryer by the IntrospectOptions.Apply function
func IntrospectWithMiddlewares(wares ...NetworkMiddleware) *IntrospectOptions {
return &IntrospectOptions{
mergeFunc: func(opts *IntrospectOptions) {
opts.wares = append(opts.wares, wares...)
},
wares: wares,
}
return introspectOptsFunc(func(opts *IntrospectOptions) {
opts.wares = append(opts.wares, wares...)
})
}

// IntrospectWithHTTPClient returns an instance of graphql.IntrospectOptions with given client
// to be pass to an instance of a graphql.Queryer by the IntrospectOptions.Apply function
func IntrospectWithHTTPClient(client *http.Client) *IntrospectOptions {
return &IntrospectOptions{
mergeFunc: func(opts *IntrospectOptions) {
opts.client = client
},
client: client,
}
return introspectOptsFunc(func(opts *IntrospectOptions) {
opts.client = client
})
}

func introspectOptsFunc(fn func(opts *IntrospectOptions)) *IntrospectOptions {
return &IntrospectOptions{mergeFunc: fn}
opts := &IntrospectOptions{mergeFunc: fn}
opts.mergeFunc(opts)
return opts
}

// IntrospectWithHTTPClient returns an instance of graphql.IntrospectOptions with given context
Expand Down