diff --git a/CHANGELOG.md b/CHANGELOG.md index 944247a..3015646 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ... +## [0.7.9] + +- build: make schema compatible with dgraph v22 +- buid: add options to contrib/dgraph configs file to change ports. +- refactor: update resolvers with bridge query +- refactor: make DgraphQueryResolverRaw obsolete with new Dgraph bridge resolver using proper inputs [WIP] +- fix/schema:Fix duplicate issue with artefact case; make w_* effective with *Filter input in schema. +- fix/updateAretefact: allow duplicate artefacts to be added to circles even if not at root circle. +- Update go.mod + + + ## [0.7.8] ### Fixed diff --git a/Makefile b/Makefile index 7ab21f5..47e67b3 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ BINARY := f6 #DGRAPH_RELEASE := v21.03.1 #DGRAPH_RELEASE := v21.12.0 DGRAPH_RELEASE := v22.0.2 -CLIENT_RELEASE := 0.7.8 +CLIENT_RELEASE := 0.7.9 $(eval BRANCH_NAME=$(shell git rev-parse --abbrev-ref HEAD)) $(eval COMMIT_NAME=$(shell git rev-parse --short HEAD)) $(eval RELEASE_VERSION=$(shell git tag -l --sort=-creatordate | head -n 1)) diff --git a/README.md b/README.md index 59f11d0..d40078c 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Using Fractale for your organization offers the following capabilities and featu Download and extract the given release - wget https://github.com/fractal6/fractal6.go/releases/download/0.7.8/fractal6-amd64.zip + wget https://github.com/fractal6/fractal6.go/releases/download/0.7.9/fractal6-amd64.zip unzip fractal6-adm64.zip && mv fractal6-amd64 fractal6 cd fractal6 diff --git a/graph/contract_op.go b/graph/contract_op.go index 5f61365..69eb718 100644 --- a/graph/contract_op.go +++ b/graph/contract_op.go @@ -72,9 +72,8 @@ func contractEventHook(uctx *model.UserCtx, cid, tid string, event *model.EventR } } for _, c := range contract.PendingCandidates { - if c.Email == nil { continue } - if i := auth.IsMember("email", *c.Email, contract.Tension.Receiverid); i >= 0 { - return false, contract, fmt.Errorf("Candidate '%s' is already member.", *c.Email) + if i := auth.IsMember("email", c.Email, contract.Tension.Receiverid); i >= 0 { + return false, contract, fmt.Errorf("Candidate '%s' is already member.", c.Email) } } case model.TensionEventMemberLinked: diff --git a/graph/generated/root_.generated.go b/graph/generated/root_.generated.go index f639211..e81f0ca 100644 --- a/graph/generated/root_.generated.go +++ b/graph/generated/root_.generated.go @@ -39,7 +39,6 @@ type DirectiveRoot struct { CacheControl func(ctx context.Context, obj interface{}, next graphql.Resolver, maxAge int) (res interface{}, err error) Cascade func(ctx context.Context, obj interface{}, next graphql.Resolver, fields []*string) (res interface{}, err error) Custom func(ctx context.Context, obj interface{}, next graphql.Resolver, http *model.CustomHTTP, dql *string) (res interface{}, err error) - Default func(ctx context.Context, obj interface{}, next graphql.Resolver, add *model.DgraphDefault, update *model.DgraphDefault) (res interface{}, err error) Dgraph func(ctx context.Context, obj interface{}, next graphql.Resolver, typeArg *string, pred *string) (res interface{}, err error) Generate func(ctx context.Context, obj interface{}, next graphql.Resolver, query *model.GenerateQueryParams, mutation *model.GenerateMutationParams, subscription *bool) (res interface{}, err error) HasInverse func(ctx context.Context, obj interface{}, next graphql.Resolver, field string) (res interface{}, err error) @@ -116,7 +115,7 @@ type DirectiveRoot struct { Hook_updateUserInput func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) Hook_updateVote func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) Hook_updateVoteInput func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) - Id func(ctx context.Context, obj interface{}, next graphql.Resolver, interfaceArg *bool) (res interface{}, err error) + Id func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) IsContractValidator func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) Lambda func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) LambdaOnMutate func(ctx context.Context, obj interface{}, next graphql.Resolver, add *bool, update *bool, delete *bool) (res interface{}, err error) @@ -8997,7 +8996,6 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputCustomHTTP, ec.unmarshalInputDateTimeFilter, ec.unmarshalInputDateTimeRange, - ec.unmarshalInputDgraphDefault, ec.unmarshalInputEventCountFilter, ec.unmarshalInputEventCountOrder, ec.unmarshalInputEventCountPatch, @@ -9511,7 +9509,7 @@ type Comment { type Reaction { id: ID! - reactionid: String + reactionid: String! user(filter: UserFilter): User! comment(filter: CommentFilter): Comment! type_: Int! @@ -9628,9 +9626,9 @@ type User { type PendingUser { id: ID! updatedAt: DateTime - username: String + username: String! password: String @hidden - email: String @hidden + email: String! @hidden email_token: String @hidden token: String @hidden contracts(filter: ContractFilter, order: ContractOrder, first: Int, offset: Int): [Contract!] @@ -9827,37 +9825,35 @@ enum Lang { # Dgraph.Authorization {"Header":"X-Frac6-Auth","Namespace":"https://fractale.co/jwt/claims","Algo":"RS256","VerificationKey":"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqfBbJAanlwf2mYlBszBA\nxgHw3hTu6gZ9nmej+5fCCdyA85IXhw14+F14o+vLogPe/giFuPMpG9eCOPWKvL/T\nGyahW5Lm8TRB4Pf54fZq5+VKdf5/i9u2e8CelpFvT+zLRdBmNVy9H9MitOF9mSGK\nHviPH1nHzU6TGvuVf44s60LAKliiwagALF+T/3ReDFhoqdLb1J3w4JkxFO6Guw5p\n3aDT+RMjjz9W8XpT3+k8IHocWxcEsuWMKdhuNwOHX2l7yU+/yLOrK1nuAMH7KewC\nCT4gJOan1qFO8NKe37jeQgsuRbhtF5C+L6CKs3n+B2A3ZOYB4gzdJfMLXxW/wwr1\nRQIDAQAB\n-----END PUBLIC KEY-----"} -directive @lambdaOnMutate(add: Boolean, update: Boolean, delete: Boolean) on OBJECT|INTERFACE - -directive @cacheControl(maxAge: Int!) on QUERY - -directive @withSubscription on OBJECT|INTERFACE|FIELD_DEFINITION +directive @auth(password: AuthRule, query: AuthRule, add: AuthRule, update: AuthRule, delete: AuthRule) on OBJECT|INTERFACE -directive @secret(field: String!, pred: String) on OBJECT|INTERFACE +directive @custom(http: CustomHTTP, dql: String) on FIELD_DEFINITION directive @remote on OBJECT|INTERFACE|UNION|INPUT_OBJECT|ENUM -directive @generate(query: GenerateQueryParams, mutation: GenerateMutationParams, subscription: Boolean) on OBJECT|INTERFACE +directive @cascade(fields: [String]) on FIELD + +directive @lambda on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT|INTERFACE|FIELD_DEFINITION -directive @remoteResponse(name: String) on FIELD_DEFINITION +directive @secret(field: String!, pred: String) on OBJECT|INTERFACE -directive @custom(http: CustomHTTP, dql: String) on FIELD_DEFINITION +directive @generate(query: GenerateQueryParams, mutation: GenerateMutationParams, subscription: Boolean) on OBJECT|INTERFACE -directive @id(interface: Boolean) on FIELD_DEFINITION +directive @lambdaOnMutate(add: Boolean, update: Boolean, delete: Boolean) on OBJECT|INTERFACE -directive @default(add: DgraphDefault, update: DgraphDefault) on FIELD_DEFINITION +directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @auth(password: AuthRule, query: AuthRule, add: AuthRule, update: AuthRule, delete: AuthRule) on OBJECT|INTERFACE +directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION -directive @cascade(fields: [String]) on FIELD +directive @withSubscription on OBJECT|INTERFACE|FIELD_DEFINITION -directive @lambda on FIELD_DEFINITION +directive @id on FIELD_DEFINITION -directive @hasInverse(field: String!) on FIELD_DEFINITION +directive @remoteResponse(name: String) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @cacheControl(maxAge: Int!) on QUERY input AddBlobInput { createdBy: UserRef! @@ -10069,9 +10065,9 @@ type AddOrgaAggPayload { input AddPendingUserInput { updatedAt: DateTime - username: String @w_alter(a:"lower") + username: String! @w_alter(a:"lower") password: String - email: String @w_alter(a:"lower") + email: String! @w_alter(a:"lower") email_token: String token: String contracts: [ContractRef!] @@ -10124,7 +10120,7 @@ type AddProjectTensionPayload { } input AddReactionInput { - reactionid: String + reactionid: String! user: UserRef! @x_add(r:"ref") comment: CommentRef! @x_add(r:"ref") type_: Int! @@ -10480,7 +10476,6 @@ input ContractPatch { createdAt: DateTime @x_patch_ro updatedAt: DateTime @x_alter(r:"isOwner", f:"createdBy") message: String @x_patch_ro - contractid: String @x_patch_ro tension: TensionRef @x_patch_ro status: ContractStatus @x_patch_ro contract_type: ContractType @x_patch_ro @@ -10695,10 +10690,6 @@ type DeleteVotePayload { numUids: Int } -input DgraphDefault { - value: String -} - enum DgraphIndex { int int64 @@ -11400,7 +11391,6 @@ input NodePatch { createdBy: UserRef @x_patch_ro createdAt: DateTime @x_patch_ro updatedAt: DateTime @x_patch_ro - nameid: String @x_patch_ro rootnameid: String @x_patch_ro source: BlobRef @x_patch_ro name: String @x_patch_ro @@ -11650,9 +11640,7 @@ enum PendingUserOrderable { input PendingUserPatch { updatedAt: DateTime @x_patch_ro - username: String @w_alter(a:"lower") password: String @x_patch_ro - email: String @w_alter(a:"lower") email_token: String @x_patch_ro token: String @x_patch_ro contracts: [ContractRef!] @x_patch_ro @@ -11815,7 +11803,6 @@ enum ProjectColumnOrderable { } input ProjectColumnPatch { - name: String @x_patch_ro about: String @x_patch_ro pos: Int @x_patch_ro tensions: [ProjectTensionRef!] @x_patch_ro @@ -12045,7 +12032,6 @@ enum ReactionOrderable { } input ReactionPatch { - reactionid: String @x_patch_ro user: UserRef @x_patch_ro comment: CommentRef @x_patch_ro type_: Int @x_patch_ro @@ -12727,9 +12713,7 @@ enum UserOrderable { input UserPatch { createdAt: DateTime @x_patch_ro lastAck: DateTime @x_patch_ro - username: String @x_patch_ro name: String @x_patch - email: String @x_patch_ro password: String @x_patch_ro bio: String @x_patch @x_alter(r:"maxLen", n:280) location: String @x_patch @@ -12890,7 +12874,6 @@ input VotePatch { createdAt: DateTime @x_patch_ro updatedAt: DateTime @x_alter(r:"isOwner", f:"createdBy") message: String @x_patch_ro - voteid: String @x_patch_ro contract: ContractRef @x_patch_ro node: NodeRef @x_patch_ro data: [Int!] @x_patch_ro diff --git a/graph/generated/schema.generated.go b/graph/generated/schema.generated.go index 85bda33..378812d 100644 --- a/graph/generated/schema.generated.go +++ b/graph/generated/schema.generated.go @@ -270,30 +270,6 @@ func (ec *executionContext) dir_custom_args(ctx context.Context, rawArgs map[str return args, nil } -func (ec *executionContext) dir_default_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 *model.DgraphDefault - if tmp, ok := rawArgs["add"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("add")) - arg0, err = ec.unmarshalODgraphDefault2ᚖfractaleᚋfractal6ᚗgoᚋgraphᚋmodelᚐDgraphDefault(ctx, tmp) - if err != nil { - return nil, err - } - } - args["add"] = arg0 - var arg1 *model.DgraphDefault - if tmp, ok := rawArgs["update"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("update")) - arg1, err = ec.unmarshalODgraphDefault2ᚖfractaleᚋfractal6ᚗgoᚋgraphᚋmodelᚐDgraphDefault(ctx, tmp) - if err != nil { - return nil, err - } - } - args["update"] = arg1 - return args, nil -} - func (ec *executionContext) dir_dgraph_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -366,21 +342,6 @@ func (ec *executionContext) dir_hasInverse_args(ctx context.Context, rawArgs map return args, nil } -func (ec *executionContext) dir_id_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 *bool - if tmp, ok := rawArgs["interface"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("interface")) - arg0, err = ec.unmarshalOBoolean2ᚖbool(ctx, tmp) - if err != nil { - return nil, err - } - } - args["interface"] = arg0 - return args, nil -} - func (ec *executionContext) dir_lambdaOnMutate_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -34616,11 +34577,14 @@ func (ec *executionContext) _PendingUser_username(ctx context.Context, field gra }) if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_PendingUser_username(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -34725,18 +34689,21 @@ func (ec *executionContext) _PendingUser_email(ctx context.Context, field graphq if tmp == nil { return nil, nil } - if data, ok := tmp.(*string); ok { + if data, ok := tmp.(string); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) }) if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_PendingUser_email(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -43956,11 +43923,14 @@ func (ec *executionContext) _Reaction_reactionid(ctx context.Context, field grap }) if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Reaction_reactionid(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -58356,7 +58326,7 @@ func (ec *executionContext) unmarshalInputAddPendingUserInput(ctx context.Contex var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) - directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } + directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalNString2string(ctx, v) } directive1 := func(ctx context.Context) (interface{}, error) { a, err := ec.unmarshalNString2string(ctx, "lower") if err != nil { @@ -58372,12 +58342,10 @@ func (ec *executionContext) unmarshalInputAddPendingUserInput(ctx context.Contex if err != nil { return it, graphql.ErrorOnPath(ctx, err) } - if data, ok := tmp.(*string); ok { + if data, ok := tmp.(string); ok { it.Username = data - } else if tmp == nil { - it.Username = nil } else { - err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) + err := fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) return it, graphql.ErrorOnPath(ctx, err) } case "password": @@ -58392,7 +58360,7 @@ func (ec *executionContext) unmarshalInputAddPendingUserInput(ctx context.Contex var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email")) - directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } + directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalNString2string(ctx, v) } directive1 := func(ctx context.Context) (interface{}, error) { a, err := ec.unmarshalNString2string(ctx, "lower") if err != nil { @@ -58408,12 +58376,10 @@ func (ec *executionContext) unmarshalInputAddPendingUserInput(ctx context.Contex if err != nil { return it, graphql.ErrorOnPath(ctx, err) } - if data, ok := tmp.(*string); ok { + if data, ok := tmp.(string); ok { it.Email = data - } else if tmp == nil { - it.Email = nil } else { - err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) + err := fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) return it, graphql.ErrorOnPath(ctx, err) } case "email_token": @@ -58782,7 +58748,7 @@ func (ec *executionContext) unmarshalInputAddReactionInput(ctx context.Context, var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("reactionid")) - it.Reactionid, err = ec.unmarshalOString2ᚖstring(ctx, v) + it.Reactionid, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } @@ -61469,7 +61435,7 @@ func (ec *executionContext) unmarshalInputContractPatch(ctx context.Context, obj asMap[k] = v } - fieldsInOrder := [...]string{"createdBy", "createdAt", "updatedAt", "message", "contractid", "tension", "status", "contract_type", "closedAt", "event", "participants", "candidates", "pending_candidates", "comments", "isValidator"} + fieldsInOrder := [...]string{"createdBy", "createdAt", "updatedAt", "message", "tension", "status", "contract_type", "closedAt", "event", "participants", "candidates", "pending_candidates", "comments", "isValidator"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -61582,30 +61548,6 @@ func (ec *executionContext) unmarshalInputContractPatch(ctx context.Context, obj err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) return it, graphql.ErrorOnPath(ctx, err) } - case "contractid": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("contractid")) - directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.X_patch_ro == nil { - return nil, errors.New("directive x_patch_ro is not implemented") - } - return ec.directives.X_patch_ro(ctx, obj, directive0) - } - - tmp, err := directive1(ctx) - if err != nil { - return it, graphql.ErrorOnPath(ctx, err) - } - if data, ok := tmp.(*string); ok { - it.Contractid = data - } else if tmp == nil { - it.Contractid = nil - } else { - err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) - return it, graphql.ErrorOnPath(ctx, err) - } case "tension": var err error @@ -62364,34 +62306,6 @@ func (ec *executionContext) unmarshalInputDateTimeRange(ctx context.Context, obj return it, nil } -func (ec *executionContext) unmarshalInputDgraphDefault(ctx context.Context, obj interface{}) (model.DgraphDefault, error) { - var it model.DgraphDefault - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"value"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "value": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("value")) - it.Value, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - func (ec *executionContext) unmarshalInputEventCountFilter(ctx context.Context, obj interface{}) (model.EventCountFilter, error) { var it model.EventCountFilter asMap := map[string]interface{}{} @@ -65919,7 +65833,7 @@ func (ec *executionContext) unmarshalInputNodePatch(ctx context.Context, obj int asMap[k] = v } - fieldsInOrder := [...]string{"createdBy", "createdAt", "updatedAt", "nameid", "rootnameid", "source", "name", "about", "skills", "isRoot", "parent", "type_", "tensions_out", "tensions_in", "visibility", "mode", "rights", "isArchived", "isPersonal", "userCanJoin", "guestCanCreateTension", "watchers", "children", "labels", "roles", "projects", "pinned", "role_ext", "role_type", "color", "first_link", "second_link", "contracts", "orga_agg", "events_history"} + fieldsInOrder := [...]string{"createdBy", "createdAt", "updatedAt", "rootnameid", "source", "name", "about", "skills", "isRoot", "parent", "type_", "tensions_out", "tensions_in", "visibility", "mode", "rights", "isArchived", "isPersonal", "userCanJoin", "guestCanCreateTension", "watchers", "children", "labels", "roles", "projects", "pinned", "role_ext", "role_type", "color", "first_link", "second_link", "contracts", "orga_agg", "events_history"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -66000,30 +65914,6 @@ func (ec *executionContext) unmarshalInputNodePatch(ctx context.Context, obj int err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) return it, graphql.ErrorOnPath(ctx, err) } - case "nameid": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameid")) - directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.X_patch_ro == nil { - return nil, errors.New("directive x_patch_ro is not implemented") - } - return ec.directives.X_patch_ro(ctx, obj, directive0) - } - - tmp, err := directive1(ctx) - if err != nil { - return it, graphql.ErrorOnPath(ctx, err) - } - if data, ok := tmp.(*string); ok { - it.Nameid = data - } else if tmp == nil { - it.Nameid = nil - } else { - err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) - return it, graphql.ErrorOnPath(ctx, err) - } case "rootnameid": var err error @@ -68033,7 +67923,7 @@ func (ec *executionContext) unmarshalInputPendingUserPatch(ctx context.Context, asMap[k] = v } - fieldsInOrder := [...]string{"updatedAt", "username", "password", "email", "email_token", "token", "contracts", "subscribe"} + fieldsInOrder := [...]string{"updatedAt", "password", "email_token", "token", "contracts", "subscribe"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -68064,34 +67954,6 @@ func (ec *executionContext) unmarshalInputPendingUserPatch(ctx context.Context, err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) return it, graphql.ErrorOnPath(ctx, err) } - case "username": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) - directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } - directive1 := func(ctx context.Context) (interface{}, error) { - a, err := ec.unmarshalNString2string(ctx, "lower") - if err != nil { - return nil, err - } - if ec.directives.W_alter == nil { - return nil, errors.New("directive w_alter is not implemented") - } - return ec.directives.W_alter(ctx, obj, directive0, a) - } - - tmp, err := directive1(ctx) - if err != nil { - return it, graphql.ErrorOnPath(ctx, err) - } - if data, ok := tmp.(*string); ok { - it.Username = data - } else if tmp == nil { - it.Username = nil - } else { - err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) - return it, graphql.ErrorOnPath(ctx, err) - } case "password": var err error @@ -68116,34 +67978,6 @@ func (ec *executionContext) unmarshalInputPendingUserPatch(ctx context.Context, err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) return it, graphql.ErrorOnPath(ctx, err) } - case "email": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email")) - directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } - directive1 := func(ctx context.Context) (interface{}, error) { - a, err := ec.unmarshalNString2string(ctx, "lower") - if err != nil { - return nil, err - } - if ec.directives.W_alter == nil { - return nil, errors.New("directive w_alter is not implemented") - } - return ec.directives.W_alter(ctx, obj, directive0, a) - } - - tmp, err := directive1(ctx) - if err != nil { - return it, graphql.ErrorOnPath(ctx, err) - } - if data, ok := tmp.(*string); ok { - it.Email = data - } else if tmp == nil { - it.Email = nil - } else { - err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) - return it, graphql.ErrorOnPath(ctx, err) - } case "email_token": var err error @@ -68961,37 +68795,13 @@ func (ec *executionContext) unmarshalInputProjectColumnPatch(ctx context.Context asMap[k] = v } - fieldsInOrder := [...]string{"name", "about", "pos", "tensions", "project"} + fieldsInOrder := [...]string{"about", "pos", "tensions", "project"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { - case "name": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.X_patch_ro == nil { - return nil, errors.New("directive x_patch_ro is not implemented") - } - return ec.directives.X_patch_ro(ctx, obj, directive0) - } - - tmp, err := directive1(ctx) - if err != nil { - return it, graphql.ErrorOnPath(ctx, err) - } - if data, ok := tmp.(*string); ok { - it.Name = data - } else if tmp == nil { - it.Name = nil - } else { - err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) - return it, graphql.ErrorOnPath(ctx, err) - } case "about": var err error @@ -70215,37 +70025,13 @@ func (ec *executionContext) unmarshalInputReactionPatch(ctx context.Context, obj asMap[k] = v } - fieldsInOrder := [...]string{"reactionid", "user", "comment", "type_"} + fieldsInOrder := [...]string{"user", "comment", "type_"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { - case "reactionid": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("reactionid")) - directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.X_patch_ro == nil { - return nil, errors.New("directive x_patch_ro is not implemented") - } - return ec.directives.X_patch_ro(ctx, obj, directive0) - } - - tmp, err := directive1(ctx) - if err != nil { - return it, graphql.ErrorOnPath(ctx, err) - } - if data, ok := tmp.(*string); ok { - it.Reactionid = data - } else if tmp == nil { - it.Reactionid = nil - } else { - err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) - return it, graphql.ErrorOnPath(ctx, err) - } case "user": var err error @@ -74507,7 +74293,7 @@ func (ec *executionContext) unmarshalInputUserPatch(ctx context.Context, obj int asMap[k] = v } - fieldsInOrder := [...]string{"createdAt", "lastAck", "username", "name", "email", "password", "bio", "location", "utc", "links", "skills", "notifyByEmail", "lang", "subscriptions", "watching", "rights", "roles", "backed_roles", "tensions_created", "tensions_assigned", "contracts", "reactions", "events", "markAllAsRead", "event_count"} + fieldsInOrder := [...]string{"createdAt", "lastAck", "name", "password", "bio", "location", "utc", "links", "skills", "notifyByEmail", "lang", "subscriptions", "watching", "rights", "roles", "backed_roles", "tensions_created", "tensions_assigned", "contracts", "reactions", "events", "markAllAsRead", "event_count"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -74562,30 +74348,6 @@ func (ec *executionContext) unmarshalInputUserPatch(ctx context.Context, obj int err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) return it, graphql.ErrorOnPath(ctx, err) } - case "username": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) - directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.X_patch_ro == nil { - return nil, errors.New("directive x_patch_ro is not implemented") - } - return ec.directives.X_patch_ro(ctx, obj, directive0) - } - - tmp, err := directive1(ctx) - if err != nil { - return it, graphql.ErrorOnPath(ctx, err) - } - if data, ok := tmp.(*string); ok { - it.Username = data - } else if tmp == nil { - it.Username = nil - } else { - err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) - return it, graphql.ErrorOnPath(ctx, err) - } case "name": var err error @@ -74610,30 +74372,6 @@ func (ec *executionContext) unmarshalInputUserPatch(ctx context.Context, obj int err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) return it, graphql.ErrorOnPath(ctx, err) } - case "email": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email")) - directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.X_patch_ro == nil { - return nil, errors.New("directive x_patch_ro is not implemented") - } - return ec.directives.X_patch_ro(ctx, obj, directive0) - } - - tmp, err := directive1(ctx) - if err != nil { - return it, graphql.ErrorOnPath(ctx, err) - } - if data, ok := tmp.(*string); ok { - it.Email = data - } else if tmp == nil { - it.Email = nil - } else { - err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) - return it, graphql.ErrorOnPath(ctx, err) - } case "password": var err error @@ -76301,7 +76039,7 @@ func (ec *executionContext) unmarshalInputVotePatch(ctx context.Context, obj int asMap[k] = v } - fieldsInOrder := [...]string{"createdBy", "createdAt", "updatedAt", "message", "voteid", "contract", "node", "data"} + fieldsInOrder := [...]string{"createdBy", "createdAt", "updatedAt", "message", "contract", "node", "data"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -76414,30 +76152,6 @@ func (ec *executionContext) unmarshalInputVotePatch(ctx context.Context, obj int err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) return it, graphql.ErrorOnPath(ctx, err) } - case "voteid": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("voteid")) - directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.X_patch_ro == nil { - return nil, errors.New("directive x_patch_ro is not implemented") - } - return ec.directives.X_patch_ro(ctx, obj, directive0) - } - - tmp, err := directive1(ctx) - if err != nil { - return it, graphql.ErrorOnPath(ctx, err) - } - if data, ok := tmp.(*string); ok { - it.Voteid = data - } else if tmp == nil { - it.Voteid = nil - } else { - err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) - return it, graphql.ErrorOnPath(ctx, err) - } case "contract": var err error @@ -80425,6 +80139,9 @@ func (ec *executionContext) _PendingUser(ctx context.Context, sel ast.SelectionS out.Values[i] = ec._PendingUser_username(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } case "password": out.Values[i] = ec._PendingUser_password(ctx, field, obj) @@ -80433,6 +80150,9 @@ func (ec *executionContext) _PendingUser(ctx context.Context, sel ast.SelectionS out.Values[i] = ec._PendingUser_email(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } case "email_token": out.Values[i] = ec._PendingUser_email_token(ctx, field, obj) @@ -82507,6 +82227,9 @@ func (ec *executionContext) _Reaction(ctx context.Context, sel ast.SelectionSet, out.Values[i] = ec._Reaction_reactionid(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } case "user": out.Values[i] = ec._Reaction_user(ctx, field, obj) @@ -87457,14 +87180,6 @@ func (ec *executionContext) marshalODeleteVotePayload2ᚖfractaleᚋfractal6ᚗg return ec._DeleteVotePayload(ctx, sel, v) } -func (ec *executionContext) unmarshalODgraphDefault2ᚖfractaleᚋfractal6ᚗgoᚋgraphᚋmodelᚐDgraphDefault(ctx context.Context, v interface{}) (*model.DgraphDefault, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputDgraphDefault(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - func (ec *executionContext) unmarshalODgraphIndex2ᚕfractaleᚋfractal6ᚗgoᚋgraphᚋmodelᚐDgraphIndexᚄ(ctx context.Context, v interface{}) ([]model.DgraphIndex, error) { if v == nil { return nil, nil diff --git a/graph/model/models_gen.go b/graph/model/models_gen.go index 3993fc1..65fab06 100644 --- a/graph/model/models_gen.go +++ b/graph/model/models_gen.go @@ -222,9 +222,9 @@ type AddOrgaAggPayload struct { type AddPendingUserInput struct { UpdatedAt *string `json:"updatedAt,omitempty"` - Username *string `json:"username,omitempty"` + Username string `json:"username"` Password *string `json:"password,omitempty"` - Email *string `json:"email,omitempty"` + Email string `json:"email"` EmailToken *string `json:"email_token,omitempty"` Token *string `json:"token,omitempty"` Contracts []*ContractRef `json:"contracts,omitempty"` @@ -277,7 +277,7 @@ type AddProjectTensionPayload struct { } type AddReactionInput struct { - Reactionid *string `json:"reactionid,omitempty"` + Reactionid string `json:"reactionid"` User *UserRef `json:"user"` Comment *CommentRef `json:"comment"` Type int `json:"type_"` @@ -620,7 +620,6 @@ type ContractPatch struct { CreatedAt *string `json:"createdAt,omitempty"` UpdatedAt *string `json:"updatedAt,omitempty"` Message *string `json:"message,omitempty"` - Contractid *string `json:"contractid,omitempty"` Tension *TensionRef `json:"tension,omitempty"` Status *ContractStatus `json:"status,omitempty"` ContractType *ContractType `json:"contract_type,omitempty"` @@ -833,10 +832,6 @@ type DeleteVotePayload struct { NumUids *int `json:"numUids,omitempty"` } -type DgraphDefault struct { - Value *string `json:"value,omitempty"` -} - type Event struct { Tension *Tension `json:"tension"` EventType TensionEvent `json:"event_type"` @@ -1382,7 +1377,6 @@ type NodePatch struct { CreatedBy *UserRef `json:"createdBy,omitempty"` CreatedAt *string `json:"createdAt,omitempty"` UpdatedAt *string `json:"updatedAt,omitempty"` - Nameid *string `json:"nameid,omitempty"` Rootnameid *string `json:"rootnameid,omitempty"` Source *BlobRef `json:"source,omitempty"` Name *string `json:"name,omitempty"` @@ -1570,9 +1564,9 @@ type OrgaAggRef struct { type PendingUser struct { ID string `json:"id"` UpdatedAt *string `json:"updatedAt,omitempty"` - Username *string `json:"username,omitempty"` + Username string `json:"username"` Password *string `json:"password,omitempty"` - Email *string `json:"email,omitempty"` + Email string `json:"email"` EmailToken *string `json:"email_token,omitempty"` Token *string `json:"token,omitempty"` Contracts []*Contract `json:"contracts,omitempty"` @@ -1616,9 +1610,7 @@ type PendingUserOrder struct { type PendingUserPatch struct { UpdatedAt *string `json:"updatedAt,omitempty"` - Username *string `json:"username,omitempty"` Password *string `json:"password,omitempty"` - Email *string `json:"email,omitempty"` EmailToken *string `json:"email_token,omitempty"` Token *string `json:"token,omitempty"` Contracts []*ContractRef `json:"contracts,omitempty"` @@ -1787,7 +1779,6 @@ type ProjectColumnOrder struct { } type ProjectColumnPatch struct { - Name *string `json:"name,omitempty"` About *string `json:"about,omitempty"` Pos *int `json:"pos,omitempty"` Tensions []*ProjectTensionRef `json:"tensions,omitempty"` @@ -1888,7 +1879,7 @@ type ProjectTensionRef struct { type Reaction struct { ID string `json:"id"` - Reactionid *string `json:"reactionid,omitempty"` + Reactionid string `json:"reactionid"` User *User `json:"user"` Comment *Comment `json:"comment"` Type int `json:"type_"` @@ -1920,10 +1911,9 @@ type ReactionOrder struct { } type ReactionPatch struct { - Reactionid *string `json:"reactionid,omitempty"` - User *UserRef `json:"user,omitempty"` - Comment *CommentRef `json:"comment,omitempty"` - Type *int `json:"type_,omitempty"` + User *UserRef `json:"user,omitempty"` + Comment *CommentRef `json:"comment,omitempty"` + Type *int `json:"type_,omitempty"` } type ReactionRef struct { @@ -2591,9 +2581,7 @@ type UserOrder struct { type UserPatch struct { CreatedAt *string `json:"createdAt,omitempty"` LastAck *string `json:"lastAck,omitempty"` - Username *string `json:"username,omitempty"` Name *string `json:"name,omitempty"` - Email *string `json:"email,omitempty"` Password *string `json:"password,omitempty"` Bio *string `json:"bio,omitempty"` Location *string `json:"location,omitempty"` @@ -2743,7 +2731,6 @@ type VotePatch struct { CreatedAt *string `json:"createdAt,omitempty"` UpdatedAt *string `json:"updatedAt,omitempty"` Message *string `json:"message,omitempty"` - Voteid *string `json:"voteid,omitempty"` Contract *ContractRef `json:"contract,omitempty"` Node *NodeRef `json:"node,omitempty"` Data []int `json:"data,omitempty"` diff --git a/graph/notifications.go b/graph/notifications.go index 5c4d6d5..6c33392 100644 --- a/graph/notifications.go +++ b/graph/notifications.go @@ -286,9 +286,8 @@ func PushContractNotifications(notif model.ContractNotif) error { // + // Add Pending Candidates for _, c := range notif.Contract.PendingCandidates { - if c.Email == nil { continue } - users[*c.Email] = model.UserNotifInfo{ - User: model.User{Email: *c.Email, NotifyByEmail: true}, + users[c.Email] = model.UserNotifInfo{ + User: model.User{Email: c.Email, NotifyByEmail: true}, Reason: notif.Contract.Event.EventType.ToContractReason(), IsPending: true, } diff --git a/graph/reaction_resolver.go b/graph/reaction_resolver.go index f99d7ff..a077bcd 100644 --- a/graph/reaction_resolver.go +++ b/graph/reaction_resolver.go @@ -48,7 +48,7 @@ func addReactionInputHook(ctx context.Context, obj interface{}, next graphql.Res for i, input := range newData { ids := []string{uctx.Username, *input.Comment.ID, strconv.Itoa(input.Type)} reactionid := strings.Join(ids, "#") - input.Reactionid = &reactionid + input.Reactionid = reactionid newData[i] = input } diff --git a/graph/user_op.go b/graph/user_op.go index bd134a1..1d8d92b 100644 --- a/graph/user_op.go +++ b/graph/user_op.go @@ -205,18 +205,20 @@ func SyncPendingUser(username, email string) error { *contractPatch.Event.Old, *contractPatch.Event.New, ) - contractPatch.Contractid = &contractid err = db.DB.Update(db.DB.GetRootUctx(), "contract", model.UpdateContractInput{ Filter: &model.ContractFilter{ID: []string{cid}}, Set: &contractPatch, }) if err != nil { return err } + // @id field cant't be update with graphql (@debug dgraph) + err = db.DB.SetFieldById(cid, "Contract.contractid", contractid) + if err != nil { return err } // Do MaybeAddPendingNode for each invitation. if contract.Event.EventType == model.TensionEventMemberLinked || contract.Event.EventType == model.TensionEventUserJoined { // Add pending Nodes for _, pc := range contract.PendingCandidates { - if *pc.Email == email { + if pc.Email == email { _, err = MaybeAddPendingNode(username, &model.Tension{ID: contract.Tension.ID}) if err != nil { return err } } diff --git a/schema/dgraph_out.graphql b/schema/dgraph_out.graphql index 3b9e451..11ad49d 100644 --- a/schema/dgraph_out.graphql +++ b/schema/dgraph_out.graphql @@ -1,34 +1,32 @@ -directive @lambdaOnMutate(add: Boolean, update: Boolean, delete: Boolean) on OBJECT | INTERFACE - -directive @cacheControl(maxAge: Int!) on QUERY - -directive @withSubscription on OBJECT | INTERFACE | FIELD_DEFINITION +directive @auth(password: AuthRule, query: AuthRule, add: AuthRule, update: AuthRule, delete: AuthRule) on OBJECT | INTERFACE -directive @secret(field: String!, pred: String) on OBJECT | INTERFACE +directive @custom(http: CustomHTTP, dql: String) on FIELD_DEFINITION directive @remote on OBJECT | INTERFACE | UNION | INPUT_OBJECT | ENUM -directive @generate(query: GenerateQueryParams, mutation: GenerateMutationParams, subscription: Boolean) on OBJECT | INTERFACE +directive @cascade(fields: [String]) on FIELD + +directive @lambda on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION -directive @remoteResponse(name: String) on FIELD_DEFINITION +directive @secret(field: String!, pred: String) on OBJECT | INTERFACE -directive @custom(http: CustomHTTP, dql: String) on FIELD_DEFINITION +directive @generate(query: GenerateQueryParams, mutation: GenerateMutationParams, subscription: Boolean) on OBJECT | INTERFACE -directive @id(interface: Boolean) on FIELD_DEFINITION +directive @lambdaOnMutate(add: Boolean, update: Boolean, delete: Boolean) on OBJECT | INTERFACE -directive @default(add: DgraphDefault, update: DgraphDefault) on FIELD_DEFINITION +directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @auth(password: AuthRule, query: AuthRule, add: AuthRule, update: AuthRule, delete: AuthRule) on OBJECT | INTERFACE +directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION -directive @cascade(fields: [String]) on FIELD +directive @withSubscription on OBJECT | INTERFACE | FIELD_DEFINITION -directive @lambda on FIELD_DEFINITION +directive @id on FIELD_DEFINITION -directive @hasInverse(field: String!) on FIELD_DEFINITION +directive @remoteResponse(name: String) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @cacheControl(maxAge: Int!) on QUERY input AddBlobInput { createdBy: UserRef! @@ -240,9 +238,9 @@ type AddOrgaAggPayload { input AddPendingUserInput { updatedAt: DateTime - username: String + username: String! password: String - email: String + email: String! email_token: String token: String contracts: [ContractRef!] @@ -295,7 +293,7 @@ type AddProjectTensionPayload { } input AddReactionInput { - reactionid: String + reactionid: String! user: UserRef! comment: CommentRef! type_: Int! @@ -706,7 +704,6 @@ input ContractPatch { createdAt: DateTime updatedAt: DateTime message: String - contractid: String tension: TensionRef status: ContractStatus contract_type: ContractType @@ -775,8 +772,7 @@ input CustomHTTP { """ The DateTime scalar type represents date and time as a string in RFC3339 format. -For example: "1985-04-12T23:20:50.52Z" represents 20 minutes and 50.52 seconds -after the 23rd hour of April 12th, 1985 in UTC. +For example: "1985-04-12T23:20:50.52Z" represents 20 mins 50.52 secs after the 23rd hour of Apr 12th 1985 in UTC. """ scalar DateTime @@ -939,10 +935,6 @@ type DeleteVotePayload { numUids: Int } -input DgraphDefault { - value: String -} - enum DgraphIndex { int int64 @@ -1771,7 +1763,6 @@ input NodePatch { createdBy: UserRef createdAt: DateTime updatedAt: DateTime - nameid: String rootnameid: String source: BlobRef name: String @@ -1995,9 +1986,9 @@ input OrgaAggRef { type PendingUser { id: ID! updatedAt: DateTime - username: String + username: String! password: String - email: String + email: String! email_token: String token: String contracts(filter: ContractFilter, order: ContractOrder, first: Int, offset: Int): [Contract!] @@ -2061,9 +2052,7 @@ enum PendingUserOrderable { input PendingUserPatch { updatedAt: DateTime - username: String password: String - email: String email_token: String token: String contracts: [ContractRef!] @@ -2259,7 +2248,6 @@ enum ProjectColumnOrderable { } input ProjectColumnPatch { - name: String about: String pos: Int tensions: [ProjectTensionRef!] @@ -2460,7 +2448,7 @@ type Query { type Reaction { id: ID! - reactionid: String + reactionid: String! user(filter: UserFilter): User! comment(filter: CommentFilter): Comment! type_: Int! @@ -2504,7 +2492,6 @@ enum ReactionOrderable { } input ReactionPatch { - reactionid: String user: UserRef comment: CommentRef type_: Int @@ -3346,9 +3333,7 @@ enum UserOrderable { input UserPatch { createdAt: DateTime lastAck: DateTime - username: String name: String - email: String password: String bio: String location: String @@ -3536,7 +3521,6 @@ input VotePatch { createdAt: DateTime updatedAt: DateTime message: String - voteid: String contract: ContractRef node: NodeRef data: [Int!] diff --git a/schema/dgraph_schema.graphql b/schema/dgraph_schema.graphql index b36bdf8..9dfb6b7 100644 --- a/schema/dgraph_schema.graphql +++ b/schema/dgraph_schema.graphql @@ -321,7 +321,7 @@ type Reaction @auth(add:{ rule:"""query ($USERNAME: String!) { }""" }) { id: ID! - reactionid: String @id + reactionid: String! @id user: User! comment: Comment! type_: Int! @@ -450,9 +450,9 @@ type User @auth(add:{ rule:"{ $USERTYPE: {eq: \"Root\"} }" type PendingUser { id: ID! updatedAt: DateTime - username: String @id + username: String! @id password: String - email: String @id + email: String! @id email_token: String @search(by:[hash]) token: String @search(by:[hash]) contracts: [Contract!] diff --git a/schema/schema.graphql b/schema/schema.graphql index 1e801de..8e9ab52 100644 --- a/schema/schema.graphql +++ b/schema/schema.graphql @@ -307,7 +307,7 @@ type Comment { type Reaction { id: ID! - reactionid: String + reactionid: String! user(filter: UserFilter): User! comment(filter: CommentFilter): Comment! type_: Int! @@ -424,9 +424,9 @@ type User { type PendingUser { id: ID! updatedAt: DateTime - username: String + username: String! password: String @hidden - email: String @hidden + email: String! @hidden email_token: String @hidden token: String @hidden contracts(filter: ContractFilter, order: ContractOrder, first: Int, offset: Int): [Contract!] @@ -623,37 +623,35 @@ enum Lang { # Dgraph.Authorization {"Header":"X-Frac6-Auth","Namespace":"https://fractale.co/jwt/claims","Algo":"RS256","VerificationKey":"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqfBbJAanlwf2mYlBszBA\nxgHw3hTu6gZ9nmej+5fCCdyA85IXhw14+F14o+vLogPe/giFuPMpG9eCOPWKvL/T\nGyahW5Lm8TRB4Pf54fZq5+VKdf5/i9u2e8CelpFvT+zLRdBmNVy9H9MitOF9mSGK\nHviPH1nHzU6TGvuVf44s60LAKliiwagALF+T/3ReDFhoqdLb1J3w4JkxFO6Guw5p\n3aDT+RMjjz9W8XpT3+k8IHocWxcEsuWMKdhuNwOHX2l7yU+/yLOrK1nuAMH7KewC\nCT4gJOan1qFO8NKe37jeQgsuRbhtF5C+L6CKs3n+B2A3ZOYB4gzdJfMLXxW/wwr1\nRQIDAQAB\n-----END PUBLIC KEY-----"} -directive @lambdaOnMutate(add: Boolean, update: Boolean, delete: Boolean) on OBJECT|INTERFACE - -directive @cacheControl(maxAge: Int!) on QUERY - -directive @withSubscription on OBJECT|INTERFACE|FIELD_DEFINITION +directive @auth(password: AuthRule, query: AuthRule, add: AuthRule, update: AuthRule, delete: AuthRule) on OBJECT|INTERFACE -directive @secret(field: String!, pred: String) on OBJECT|INTERFACE +directive @custom(http: CustomHTTP, dql: String) on FIELD_DEFINITION directive @remote on OBJECT|INTERFACE|UNION|INPUT_OBJECT|ENUM -directive @generate(query: GenerateQueryParams, mutation: GenerateMutationParams, subscription: Boolean) on OBJECT|INTERFACE +directive @cascade(fields: [String]) on FIELD + +directive @lambda on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT|INTERFACE|FIELD_DEFINITION -directive @remoteResponse(name: String) on FIELD_DEFINITION +directive @secret(field: String!, pred: String) on OBJECT|INTERFACE -directive @custom(http: CustomHTTP, dql: String) on FIELD_DEFINITION +directive @generate(query: GenerateQueryParams, mutation: GenerateMutationParams, subscription: Boolean) on OBJECT|INTERFACE -directive @id(interface: Boolean) on FIELD_DEFINITION +directive @lambdaOnMutate(add: Boolean, update: Boolean, delete: Boolean) on OBJECT|INTERFACE -directive @default(add: DgraphDefault, update: DgraphDefault) on FIELD_DEFINITION +directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @auth(password: AuthRule, query: AuthRule, add: AuthRule, update: AuthRule, delete: AuthRule) on OBJECT|INTERFACE +directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION -directive @cascade(fields: [String]) on FIELD +directive @withSubscription on OBJECT|INTERFACE|FIELD_DEFINITION -directive @lambda on FIELD_DEFINITION +directive @id on FIELD_DEFINITION -directive @hasInverse(field: String!) on FIELD_DEFINITION +directive @remoteResponse(name: String) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @cacheControl(maxAge: Int!) on QUERY input AddBlobInput { createdBy: UserRef! @@ -865,9 +863,9 @@ type AddOrgaAggPayload { input AddPendingUserInput { updatedAt: DateTime - username: String @w_alter(a:"lower") + username: String! @w_alter(a:"lower") password: String - email: String @w_alter(a:"lower") + email: String! @w_alter(a:"lower") email_token: String token: String contracts: [ContractRef!] @@ -920,7 +918,7 @@ type AddProjectTensionPayload { } input AddReactionInput { - reactionid: String + reactionid: String! user: UserRef! @x_add(r:"ref") comment: CommentRef! @x_add(r:"ref") type_: Int! @@ -1276,7 +1274,6 @@ input ContractPatch { createdAt: DateTime @x_patch_ro updatedAt: DateTime @x_alter(r:"isOwner", f:"createdBy") message: String @x_patch_ro - contractid: String @x_patch_ro tension: TensionRef @x_patch_ro status: ContractStatus @x_patch_ro contract_type: ContractType @x_patch_ro @@ -1491,10 +1488,6 @@ type DeleteVotePayload { numUids: Int } -input DgraphDefault { - value: String -} - enum DgraphIndex { int int64 @@ -2196,7 +2189,6 @@ input NodePatch { createdBy: UserRef @x_patch_ro createdAt: DateTime @x_patch_ro updatedAt: DateTime @x_patch_ro - nameid: String @x_patch_ro rootnameid: String @x_patch_ro source: BlobRef @x_patch_ro name: String @x_patch_ro @@ -2446,9 +2438,7 @@ enum PendingUserOrderable { input PendingUserPatch { updatedAt: DateTime @x_patch_ro - username: String @w_alter(a:"lower") password: String @x_patch_ro - email: String @w_alter(a:"lower") email_token: String @x_patch_ro token: String @x_patch_ro contracts: [ContractRef!] @x_patch_ro @@ -2611,7 +2601,6 @@ enum ProjectColumnOrderable { } input ProjectColumnPatch { - name: String @x_patch_ro about: String @x_patch_ro pos: Int @x_patch_ro tensions: [ProjectTensionRef!] @x_patch_ro @@ -2841,7 +2830,6 @@ enum ReactionOrderable { } input ReactionPatch { - reactionid: String @x_patch_ro user: UserRef @x_patch_ro comment: CommentRef @x_patch_ro type_: Int @x_patch_ro @@ -3523,9 +3511,7 @@ enum UserOrderable { input UserPatch { createdAt: DateTime @x_patch_ro lastAck: DateTime @x_patch_ro - username: String @x_patch_ro name: String @x_patch - email: String @x_patch_ro password: String @x_patch_ro bio: String @x_patch @x_alter(r:"maxLen", n:280) location: String @x_patch @@ -3686,7 +3672,6 @@ input VotePatch { createdAt: DateTime @x_patch_ro updatedAt: DateTime @x_alter(r:"isOwner", f:"createdBy") message: String @x_patch_ro - voteid: String @x_patch_ro contract: ContractRef @x_patch_ro node: NodeRef @x_patch_ro data: [Int!] @x_patch_ro diff --git a/web/handlers/auth.go b/web/handlers/auth.go index 481a740..4c0a389 100644 --- a/web/handlers/auth.go +++ b/web/handlers/auth.go @@ -100,8 +100,8 @@ func Signup(w http.ResponseWriter, r *http.Request) { } else { // Create pending user _, err = db.DB.Add(db.DB.GetRootUctx(), "pendingUser", model.AddPendingUserInput{ - Email: &creds.Email, - Username: &creds.Username, + Email: creds.Email, + Username: creds.Username, Password: &passwd, EmailToken: &email_token, UpdatedAt: &now,