Skip to content

Commit f34263c

Browse files
authored
Merge pull request #37 from graphql-go/improvements
{extractor,app}: improvements related to wiring configuration.
2 parents fde62b7 + c24ff7b commit f34263c

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

app/app.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package app
33
import (
44
"fmt"
55

6+
"graphql-go/compatibility-standard-definitions/config"
67
"graphql-go/compatibility-standard-definitions/executor"
78
"graphql-go/compatibility-standard-definitions/extractor"
89
"graphql-go/compatibility-standard-definitions/puller"
@@ -12,6 +13,8 @@ import (
1213

1314
// App represents the high level entry point for the application.
1415
type App struct {
16+
// Config is the configuration of the application.
17+
Config *config.Config
1518
}
1619

1720
// RunResult represents the result of the run method.
@@ -42,7 +45,10 @@ func (app *App) Run(params RunParams) (*RunResult, error) {
4245

4346
executor := executor.New()
4447

45-
ex := extractor.New(executor)
48+
ex := extractor.New(&extractor.NewParams{
49+
Config: app.Config,
50+
Executor: executor,
51+
})
4652

4753
extractResult, err := ex.Extract(&extractor.ExtractParams{
4854
Implementation: params.Implementation,

extractor/extractor.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"os"
1010
"strings"
1111

12+
"graphql-go/compatibility-standard-definitions/config"
1213
"graphql-go/compatibility-standard-definitions/executor"
1314
"graphql-go/compatibility-standard-definitions/types"
1415
)
@@ -23,12 +24,25 @@ const introspectionQueryFilePath string = "./graphql-js-introspection/query.grap
2324
type Extractor struct {
2425
// executor is the executor component that extractor delegates the execution of a graphql introspection query.
2526
executor *executor.Executor
27+
28+
// cfg is the configuration of the application.
29+
cfg *config.Config
2630
}
2731

28-
// New returns a pointer to a Extractor struct.
29-
func New(executor *executor.Executor) *Extractor {
32+
// NewParams represents the paramters for the new method.
33+
type NewParams struct {
34+
// Executor is the executor parameter.
35+
Executor *executor.Executor
36+
37+
// Config is the configuration parameter.
38+
Config *config.Config
39+
}
40+
41+
// New returns a pointer to an Extractor struct.
42+
func New(params *NewParams) *Extractor {
3043
return &Extractor{
31-
executor: executor,
44+
executor: params.Executor,
45+
cfg: params.Config,
3246
}
3347
}
3448

@@ -137,7 +151,9 @@ func (e *Extractor) parseSpec() (types.SpecificationIntrospection, error) {
137151
}
138152
}
139153

140-
log.Println(headingsLevel2)
154+
if e.cfg.IsDebug {
155+
log.Println(headingsLevel2)
156+
}
141157

142158
spec := types.SpecificationIntrospection{
143159
QueryResult: types.IntrospectionQueryResult{},

main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ func main() {
1919
log.Fatal(err)
2020
}
2121

22-
app := mainApp.App{}
22+
app := mainApp.App{
23+
Config: cfg,
24+
}
2325

2426
runResult, err := app.Run(mainApp.RunParams{
2527
Specification: cfg.GraphqlSpecification,

0 commit comments

Comments
 (0)