Skip to content

Commit

Permalink
docs : embedding schema in generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
Suraj Chafle committed Sep 2, 2022
1 parent 2ba8040 commit 12e967b
Show file tree
Hide file tree
Showing 26 changed files with 110 additions and 146 deletions.
8 changes: 4 additions & 4 deletions _examples/federation/accounts/gqlgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ schema:

# Where should the generated server code go?
exec:
filename: graph/generated/generated.go
package: generated
filename: graph/generated.go
package: graph

federation:
filename: graph/generated/federation.go
package: generated
filename: graph/federation.go
package: graph

# Where should any generated models go?
model:
Expand Down
5 changes: 2 additions & 3 deletions _examples/federation/accounts/graph/entity.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package graph
import (
"context"

"github.com/99designs/gqlgen/_examples/federation/accounts/graph/generated"
"github.com/99designs/gqlgen/_examples/federation/accounts/graph/model"
)

Expand All @@ -31,7 +30,7 @@ func (r *entityResolver) FindUserByID(ctx context.Context, id string) (*model.Us
}, nil
}

// Entity returns generated.EntityResolver implementation.
func (r *Resolver) Entity() generated.EntityResolver { return &entityResolver{r} }
// Entity returns EntityResolver implementation.
func (r *Resolver) Entity() EntityResolver { return &entityResolver{r} }

type entityResolver struct{ *Resolver }

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions _examples/federation/accounts/graph/schema.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package graph
import (
"context"

"github.com/99designs/gqlgen/_examples/federation/accounts/graph/generated"
"github.com/99designs/gqlgen/_examples/federation/accounts/graph/model"
)

Expand All @@ -23,7 +22,7 @@ func (r *queryResolver) Me(ctx context.Context) (*model.User, error) {
}, nil
}

// Query returns generated.QueryResolver implementation.
func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} }
// Query returns QueryResolver implementation.
func (r *Resolver) Query() QueryResolver { return &queryResolver{r} }

type queryResolver struct{ *Resolver }
3 changes: 1 addition & 2 deletions _examples/federation/accounts/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"os"

"github.com/99designs/gqlgen/_examples/federation/accounts/graph"
"github.com/99designs/gqlgen/_examples/federation/accounts/graph/generated"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/handler/debug"
"github.com/99designs/gqlgen/graphql/playground"
Expand All @@ -21,7 +20,7 @@ func main() {
port = defaultPort
}

srv := handler.NewDefaultServer(generated.NewExecutableSchema(generated.Config{Resolvers: &graph.Resolver{}}))
srv := handler.NewDefaultServer(graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}}))
srv.Use(&debug.Tracer{})

http.Handle("/", playground.Handler("GraphQL playground", "/query"))
Expand Down
8 changes: 4 additions & 4 deletions _examples/federation/products/gqlgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ schema:

# Where should the generated server code go?
exec:
filename: graph/generated/generated.go
package: generated
filename: graph/generated.go
package: graph

federation:
filename: graph/generated/federation.go
package: generated
filename: graph/federation.go
package: graph

# Where should any generated models go?
model:
Expand Down
5 changes: 2 additions & 3 deletions _examples/federation/products/graph/entity.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package graph
import (
"context"

"github.com/99designs/gqlgen/_examples/federation/products/graph/generated"
"github.com/99designs/gqlgen/_examples/federation/products/graph/model"
)

Expand Down Expand Up @@ -38,7 +37,7 @@ func (r *entityResolver) FindProductByUpc(ctx context.Context, upc string) (*mod
return nil, nil
}

// Entity returns generated.EntityResolver implementation.
func (r *Resolver) Entity() generated.EntityResolver { return &entityResolver{r} }
// Entity returns EntityResolver implementation.
func (r *Resolver) Entity() EntityResolver { return &entityResolver{r} }

type entityResolver struct{ *Resolver }

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions _examples/federation/products/graph/schema.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package graph
import (
"context"

"github.com/99designs/gqlgen/_examples/federation/products/graph/generated"
"github.com/99designs/gqlgen/_examples/federation/products/graph/model"
)

Expand All @@ -15,7 +14,7 @@ func (r *queryResolver) TopProducts(ctx context.Context, first *int) ([]*model.P
return hats, nil
}

// Query returns generated.QueryResolver implementation.
func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} }
// Query returns QueryResolver implementation.
func (r *Resolver) Query() QueryResolver { return &queryResolver{r} }

type queryResolver struct{ *Resolver }
3 changes: 1 addition & 2 deletions _examples/federation/products/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"os"

"github.com/99designs/gqlgen/_examples/federation/products/graph"
"github.com/99designs/gqlgen/_examples/federation/products/graph/generated"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/handler/debug"
"github.com/99designs/gqlgen/graphql/playground"
Expand All @@ -21,7 +20,7 @@ func main() {
port = defaultPort
}

srv := handler.NewDefaultServer(generated.NewExecutableSchema(generated.Config{Resolvers: &graph.Resolver{}}))
srv := handler.NewDefaultServer(graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}}))
srv.Use(&debug.Tracer{})

http.Handle("/", playground.Handler("GraphQL playground", "/query"))
Expand Down
8 changes: 4 additions & 4 deletions _examples/federation/reviews/gqlgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ schema:

# Where should the generated server code go?
exec:
filename: graph/generated/generated.go
package: generated
filename: graph/generated.go
package: graph

federation:
filename: graph/generated/federation.go
package: generated
filename: graph/federation.go
package: graph

# Where should any generated models go?
model:
Expand Down
5 changes: 2 additions & 3 deletions _examples/federation/reviews/graph/entity.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package graph
import (
"context"

"github.com/99designs/gqlgen/_examples/federation/reviews/graph/generated"
"github.com/99designs/gqlgen/_examples/federation/reviews/graph/model"
)

Expand Down Expand Up @@ -36,7 +35,7 @@ func (r *entityResolver) FindUserByID(ctx context.Context, id string) (*model.Us
}, nil
}

// Entity returns generated.EntityResolver implementation.
func (r *Resolver) Entity() generated.EntityResolver { return &entityResolver{r} }
// Entity returns EntityResolver implementation.
func (r *Resolver) Entity() EntityResolver { return &entityResolver{r} }

type entityResolver struct{ *Resolver }

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 12e967b

Please sign in to comment.