(ctx context.Context, m schema.Mutation)
| 26 | } |
| 27 | |
| 28 | func resolveLogin(ctx context.Context, m schema.Mutation) (*resolve.Resolved, bool) { |
| 29 | glog.Info("Got login request") |
| 30 | |
| 31 | input := getLoginInput(m) |
| 32 | resp, err := (&edgraph.Server{}).Login(ctx, &dgoapi.LoginRequest{ |
| 33 | Userid: input.UserId, |
| 34 | Password: input.Password, |
| 35 | Namespace: input.Namespace, |
| 36 | RefreshToken: input.RefreshToken, |
| 37 | }) |
| 38 | if err != nil { |
| 39 | return resolve.EmptyResult(m, err), false |
| 40 | } |
| 41 | |
| 42 | jwt := &dgoapi.Jwt{} |
| 43 | if err := proto.Unmarshal(resp.GetJson(), jwt); err != nil { |
| 44 | return resolve.EmptyResult(m, err), false |
| 45 | } |
| 46 | |
| 47 | return resolve.DataResult( |
| 48 | m, |
| 49 | map[string]interface{}{ |
| 50 | m.Name(): map[string]interface{}{ |
| 51 | "response": map[string]interface{}{ |
| 52 | "accessJWT": jwt.AccessJwt, |
| 53 | "refreshJWT": jwt.RefreshJwt}}}, |
| 54 | nil, |
| 55 | ), true |
| 56 | |
| 57 | } |
| 58 | |
| 59 | func getLoginInput(m schema.Mutation) *loginInput { |
| 60 | // We should be able to convert these to string as GraphQL schema validation should ensure this. |
nothing calls this directly
no test coverage detected