working on auth.
mailer, basic setup with html template and a dev treansport
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
extend type Mutation {
|
||||
login(username: String!, email: String!): Boolean!
|
||||
login(email: String!, pwd: String!): AuthUser!
|
||||
logout: Boolean!
|
||||
}
|
||||
|
||||
extend type Query {
|
||||
"""
|
||||
me, is current AuthUser info
|
||||
"""
|
||||
me: AuthUser
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ package graph
|
||||
|
||||
// This file will be automatically regenerated based on the schema, any resolver implementations
|
||||
// will be copied through when generating and any unknown code will be moved to the end.
|
||||
// Code generated by github.com/99designs/gqlgen version v0.17.55
|
||||
// Code generated by github.com/99designs/gqlgen version v0.17.56
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
// Login is the resolver for the login field.
|
||||
func (r *mutationResolver) Login(ctx context.Context, username string, email string) (bool, error) {
|
||||
func (r *mutationResolver) Login(ctx context.Context, email string, pwd string) (*model.AuthUser, error) {
|
||||
panic(fmt.Errorf("not implemented: Login - login"))
|
||||
}
|
||||
|
@@ -273,6 +273,20 @@ func (ec *executionContext) _AuthUser(ctx context.Context, sel ast.SelectionSet,
|
||||
|
||||
// region ***************************** type.gotpl *****************************
|
||||
|
||||
func (ec *executionContext) marshalNAuthUser2gitserverᚗinᚋpatialtechᚋranoᚋgraphᚋmodelᚐAuthUser(ctx context.Context, sel ast.SelectionSet, v model.AuthUser) graphql.Marshaler {
|
||||
return ec._AuthUser(ctx, sel, &v)
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalNAuthUser2ᚖgitserverᚗinᚋpatialtechᚋranoᚋgraphᚋmodelᚐAuthUser(ctx context.Context, sel ast.SelectionSet, v *model.AuthUser) graphql.Marshaler {
|
||||
if v == nil {
|
||||
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
||||
ec.Errorf(ctx, "the requested element is null which the schema does not allow")
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
return ec._AuthUser(ctx, sel, v)
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalOAuthUser2ᚖgitserverᚗinᚋpatialtechᚋranoᚋgraphᚋmodelᚐAuthUser(ctx context.Context, sel ast.SelectionSet, v *model.AuthUser) graphql.Marshaler {
|
||||
if v == nil {
|
||||
return graphql.Null
|
@@ -18,11 +18,10 @@ import (
|
||||
// region ************************** generated!.gotpl **************************
|
||||
|
||||
type MutationResolver interface {
|
||||
Login(ctx context.Context, username string, email string) (bool, error)
|
||||
Login(ctx context.Context, email string, pwd string) (*model.AuthUser, error)
|
||||
Logout(ctx context.Context) (bool, error)
|
||||
}
|
||||
type QueryResolver interface {
|
||||
HeartBeat(ctx context.Context) (bool, error)
|
||||
Me(ctx context.Context) (*model.AuthUser, error)
|
||||
}
|
||||
|
||||
@@ -33,24 +32,24 @@ type QueryResolver interface {
|
||||
func (ec *executionContext) field_Mutation_login_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
|
||||
var err error
|
||||
args := map[string]interface{}{}
|
||||
arg0, err := ec.field_Mutation_login_argsUsername(ctx, rawArgs)
|
||||
arg0, err := ec.field_Mutation_login_argsEmail(ctx, rawArgs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["username"] = arg0
|
||||
arg1, err := ec.field_Mutation_login_argsEmail(ctx, rawArgs)
|
||||
args["email"] = arg0
|
||||
arg1, err := ec.field_Mutation_login_argsPwd(ctx, rawArgs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["email"] = arg1
|
||||
args["pwd"] = arg1
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field_Mutation_login_argsUsername(
|
||||
func (ec *executionContext) field_Mutation_login_argsEmail(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]interface{},
|
||||
) (string, error) {
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("username"))
|
||||
if tmp, ok := rawArgs["username"]; ok {
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("email"))
|
||||
if tmp, ok := rawArgs["email"]; ok {
|
||||
return ec.unmarshalNString2string(ctx, tmp)
|
||||
}
|
||||
|
||||
@@ -58,12 +57,12 @@ func (ec *executionContext) field_Mutation_login_argsUsername(
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Mutation_login_argsEmail(
|
||||
func (ec *executionContext) field_Mutation_login_argsPwd(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]interface{},
|
||||
) (string, error) {
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("email"))
|
||||
if tmp, ok := rawArgs["email"]; ok {
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("pwd"))
|
||||
if tmp, ok := rawArgs["pwd"]; ok {
|
||||
return ec.unmarshalNString2string(ctx, tmp)
|
||||
}
|
||||
|
||||
@@ -116,7 +115,7 @@ func (ec *executionContext) _Mutation_login(ctx context.Context, field graphql.C
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return ec.resolvers.Mutation().Login(rctx, fc.Args["username"].(string), fc.Args["email"].(string))
|
||||
return ec.resolvers.Mutation().Login(rctx, fc.Args["email"].(string), fc.Args["pwd"].(string))
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
@@ -128,9 +127,9 @@ func (ec *executionContext) _Mutation_login(ctx context.Context, field graphql.C
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(bool)
|
||||
res := resTmp.(*model.AuthUser)
|
||||
fc.Result = res
|
||||
return ec.marshalNBoolean2bool(ctx, field.Selections, res)
|
||||
return ec.marshalNAuthUser2ᚖgitserverᚗinᚋpatialtechᚋranoᚋgraphᚋmodelᚐAuthUser(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_Mutation_login(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
@@ -140,7 +139,17 @@ func (ec *executionContext) fieldContext_Mutation_login(ctx context.Context, fie
|
||||
IsMethod: true,
|
||||
IsResolver: true,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
return nil, errors.New("field of type Boolean does not have child fields")
|
||||
switch field.Name {
|
||||
case "id":
|
||||
return ec.fieldContext_AuthUser_id(ctx, field)
|
||||
case "email":
|
||||
return ec.fieldContext_AuthUser_email(ctx, field)
|
||||
case "displayName":
|
||||
return ec.fieldContext_AuthUser_displayName(ctx, field)
|
||||
case "roleID":
|
||||
return ec.fieldContext_AuthUser_roleID(ctx, field)
|
||||
}
|
||||
return nil, fmt.Errorf("no field named %q was found under type AuthUser", field.Name)
|
||||
},
|
||||
}
|
||||
defer func() {
|
||||
@@ -201,50 +210,6 @@ func (ec *executionContext) fieldContext_Mutation_logout(_ context.Context, fiel
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Query_heartBeat(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Query_heartBeat(ctx, field)
|
||||
if err != nil {
|
||||
return graphql.Null
|
||||
}
|
||||
ctx = graphql.WithFieldContext(ctx, fc)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
ret = graphql.Null
|
||||
}
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return ec.resolvers.Query().HeartBeat(rctx)
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return graphql.Null
|
||||
}
|
||||
if resTmp == nil {
|
||||
if !graphql.HasFieldError(ctx, fc) {
|
||||
ec.Errorf(ctx, "must not be null")
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(bool)
|
||||
fc.Result = res
|
||||
return ec.marshalNBoolean2bool(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_Query_heartBeat(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "Query",
|
||||
Field: field,
|
||||
IsMethod: true,
|
||||
IsResolver: true,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
return nil, errors.New("field of type Boolean does not have child fields")
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Query_me(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Query_me(ctx, field)
|
||||
if err != nil {
|
||||
@@ -512,28 +477,6 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
|
||||
switch field.Name {
|
||||
case "__typename":
|
||||
out.Values[i] = graphql.MarshalString("Query")
|
||||
case "heartBeat":
|
||||
field := field
|
||||
|
||||
innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
}
|
||||
}()
|
||||
res = ec._Query_heartBeat(ctx, field)
|
||||
if res == graphql.Null {
|
||||
atomic.AddUint32(&fs.Invalids, 1)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
rrm := func(ctx context.Context) graphql.Marshaler {
|
||||
return ec.OperationContext.RootResolverMiddleware(ctx,
|
||||
func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
|
||||
}
|
||||
|
||||
out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) })
|
||||
case "me":
|
||||
field := field
|
||||
|
@@ -48,13 +48,12 @@ type ComplexityRoot struct {
|
||||
}
|
||||
|
||||
Mutation struct {
|
||||
Login func(childComplexity int, username string, email string) int
|
||||
Login func(childComplexity int, email string, pwd string) int
|
||||
Logout func(childComplexity int) int
|
||||
}
|
||||
|
||||
Query struct {
|
||||
HeartBeat func(childComplexity int) int
|
||||
Me func(childComplexity int) int
|
||||
Me func(childComplexity int) int
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +114,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
||||
return 0, false
|
||||
}
|
||||
|
||||
return e.complexity.Mutation.Login(childComplexity, args["username"].(string), args["email"].(string)), true
|
||||
return e.complexity.Mutation.Login(childComplexity, args["email"].(string), args["pwd"].(string)), true
|
||||
|
||||
case "Mutation.logout":
|
||||
if e.complexity.Mutation.Logout == nil {
|
||||
@@ -124,13 +123,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
||||
|
||||
return e.complexity.Mutation.Logout(childComplexity), true
|
||||
|
||||
case "Query.heartBeat":
|
||||
if e.complexity.Query.HeartBeat == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.Query.HeartBeat(childComplexity), true
|
||||
|
||||
case "Query.me":
|
||||
if e.complexity.Query.Me == nil {
|
||||
break
|
||||
@@ -143,12 +135,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
||||
}
|
||||
|
||||
func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
|
||||
rc := graphql.GetOperationContext(ctx)
|
||||
ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)}
|
||||
opCtx := graphql.GetOperationContext(ctx)
|
||||
ec := executionContext{opCtx, e, 0, 0, make(chan graphql.DeferredResult)}
|
||||
inputUnmarshalMap := graphql.BuildUnmarshalerMap()
|
||||
first := true
|
||||
|
||||
switch rc.Operation.Operation {
|
||||
switch opCtx.Operation.Operation {
|
||||
case ast.Query:
|
||||
return func(ctx context.Context) *graphql.Response {
|
||||
var response graphql.Response
|
||||
@@ -156,7 +148,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
|
||||
if first {
|
||||
first = false
|
||||
ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap)
|
||||
data = ec._Query(ctx, rc.Operation.SelectionSet)
|
||||
data = ec._Query(ctx, opCtx.Operation.SelectionSet)
|
||||
} else {
|
||||
if atomic.LoadInt32(&ec.pendingDeferred) > 0 {
|
||||
result := <-ec.deferredResults
|
||||
@@ -186,7 +178,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
|
||||
}
|
||||
first = false
|
||||
ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap)
|
||||
data := ec._Mutation(ctx, rc.Operation.SelectionSet)
|
||||
data := ec._Mutation(ctx, opCtx.Operation.SelectionSet)
|
||||
var buf bytes.Buffer
|
||||
data.MarshalGQL(&buf)
|
||||
|
||||
@@ -242,15 +234,12 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er
|
||||
}
|
||||
|
||||
var sources = []*ast.Source{
|
||||
{Name: "../auth.graphql", Input: `extend type Mutation {
|
||||
login(username: String!, email: String!): Boolean!
|
||||
{Name: "../account.graphql", Input: `extend type Mutation {
|
||||
login(email: String!, pwd: String!): AuthUser!
|
||||
logout: Boolean!
|
||||
}
|
||||
|
||||
extend type Query {
|
||||
"""
|
||||
me, is current AuthUser info
|
||||
"""
|
||||
me: AuthUser
|
||||
}
|
||||
|
||||
@@ -261,15 +250,13 @@ type AuthUser {
|
||||
roleID: Int!
|
||||
}
|
||||
`, BuiltIn: false},
|
||||
{Name: "../index.graphql", Input: `# GraphQL schema example
|
||||
{Name: "../root.graphql", Input: `# GraphQL schema example
|
||||
#
|
||||
# https://gqlgen.com/getting-started/
|
||||
|
||||
type Mutation
|
||||
|
||||
type Query {
|
||||
heartBeat: Boolean!
|
||||
}
|
||||
type Query
|
||||
|
||||
"""
|
||||
Maps a Time GraphQL scalar to a Go time.Time struct.
|
||||
|
@@ -1,28 +0,0 @@
|
||||
package graph
|
||||
|
||||
// This file will be automatically regenerated based on the schema, any resolver implementations
|
||||
// will be copied through when generating and any unknown code will be moved to the end.
|
||||
// Code generated by github.com/99designs/gqlgen version v0.17.55
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
graph "gitserver.in/patialtech/rano/graph/generated"
|
||||
)
|
||||
|
||||
// HeartBeat is the resolver for the heartBeat field.
|
||||
func (r *queryResolver) HeartBeat(ctx context.Context) (bool, error) {
|
||||
// do needful checkup
|
||||
//
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// Mutation returns graph.MutationResolver implementation.
|
||||
func (r *Resolver) Mutation() graph.MutationResolver { return &mutationResolver{r} }
|
||||
|
||||
// Query returns graph.QueryResolver implementation.
|
||||
func (r *Resolver) Query() graph.QueryResolver { return &queryResolver{r} }
|
||||
|
||||
type mutationResolver struct{ *Resolver }
|
||||
type queryResolver struct{ *Resolver }
|
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/99designs/gqlgen/graphql/playground"
|
||||
"github.com/vektah/gqlparser/v2/gqlerror"
|
||||
"gitserver.in/patialtech/rano/graph/generated"
|
||||
"gitserver.in/patialtech/rano/pkg/logger"
|
||||
"gitserver.in/patialtech/rano/util/logger"
|
||||
)
|
||||
|
||||
// This file will not be regenerated automatically.
|
||||
|
@@ -4,9 +4,7 @@
|
||||
|
||||
type Mutation
|
||||
|
||||
type Query {
|
||||
heartBeat: Boolean!
|
||||
}
|
||||
type Query
|
||||
|
||||
"""
|
||||
Maps a Time GraphQL scalar to a Go time.Time struct.
|
18
graph/root.resolvers.go
Normal file
18
graph/root.resolvers.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package graph
|
||||
|
||||
// This file will be automatically regenerated based on the schema, any resolver implementations
|
||||
// will be copied through when generating and any unknown code will be moved to the end.
|
||||
// Code generated by github.com/99designs/gqlgen version v0.17.56
|
||||
|
||||
import (
|
||||
"gitserver.in/patialtech/rano/graph/generated"
|
||||
)
|
||||
|
||||
// Mutation returns generated.MutationResolver implementation.
|
||||
func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} }
|
||||
|
||||
// Query returns generated.QueryResolver implementation.
|
||||
func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} }
|
||||
|
||||
type mutationResolver struct{ *Resolver }
|
||||
type queryResolver struct{ *Resolver }
|
@@ -8,7 +8,7 @@ import (
|
||||
"gitserver.in/patialtech/mux/middleware"
|
||||
"gitserver.in/patialtech/rano/config"
|
||||
"gitserver.in/patialtech/rano/graph"
|
||||
"gitserver.in/patialtech/rano/pkg/logger"
|
||||
"gitserver.in/patialtech/rano/util/logger"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
Reference in New Issue
Block a user