Skip to content

Commit

Permalink
feat(relay): Update tmpl for relay spec (mutation, obj id)
Browse files Browse the repository at this point in the history
  • Loading branch information
gfanton committed Sep 11, 2018
1 parent 459892b commit f5ee4f1
Show file tree
Hide file tree
Showing 16 changed files with 2,006 additions and 682 deletions.
2 changes: 1 addition & 1 deletion core/Makefile
Expand Up @@ -132,5 +132,5 @@ api/p2p/kind.gen.go: $(PROTOS)
goimports -w ./api/p2p

api/node/graphql/service.gen.graphql: $(PROTOS)
$(PROTOC) $(PROTOC_OPTS) --gotemplate_out=debug=false,all=true,template_dir=./api/node:./api/node/graphql ./api/node/service.proto
$(PROTOC) $(PROTOC_OPTS) --gotemplate_out=debug=true,all=true,template_dir=./api/node:./api/node/graphql ./api/node/service.proto
cd ./api/node/graphql && $(GQLGEN) -v gen
28 changes: 13 additions & 15 deletions core/api/node/graphql/converts.go
Expand Up @@ -28,19 +28,19 @@ func convertContactStatus(value entity.Contact_Status) *model.BertyEntityContact
return &ret
}

func convertContact(contact *entity.Contact, err error) (*model.BertyEntityContact, error) {
func convertContact(contact *entity.Contact) *model.BertyEntityContact {
if contact == nil {
return &model.BertyEntityContact{}, err
return &model.BertyEntityContact{}
}

return &model.BertyEntityContact{
ID: &contact.ID,
ID: contact.ID,
Status: convertContactStatus(contact.Status),
DisplayName: &contact.DisplayName,
CreatedAt: &scalar.DateTime{Value: &contact.CreatedAt},
UpdatedAt: &scalar.DateTime{Value: &contact.UpdatedAt},
DeletedAt: &scalar.DateTime{Value: contact.DeletedAt},
}, err
}
}

func convertConversationMemberStatus(value entity.ConversationMember_Status) *model.BertyEntityConversationMemberStatus {
Expand All @@ -64,12 +64,10 @@ func convertConversationMember(conversationMember *entity.ConversationMember) *m
return &model.BertyEntityConversationMember{}
}

contact, _ := convertContact(conversationMember.Contact, nil)

return &model.BertyEntityConversationMember{
ID: &conversationMember.ID,
ID: conversationMember.ID,
Status: convertConversationMemberStatus(conversationMember.Status),
Contact: contact,
Contact: convertContact(conversationMember.Contact),
ConversationID: &conversationMember.ConversationID,
ContactID: &conversationMember.ContactID,
CreatedAt: &scalar.DateTime{Value: &conversationMember.CreatedAt},
Expand All @@ -78,9 +76,9 @@ func convertConversationMember(conversationMember *entity.ConversationMember) *m
}
}

func convertConversation(conversation *entity.Conversation, err error) (*model.BertyEntityConversation, error) {
func convertConversation(conversation *entity.Conversation) *model.BertyEntityConversation {
if conversation == nil {
return &model.BertyEntityConversation{}, err
return &model.BertyEntityConversation{}
}

var members []*model.BertyEntityConversationMember
Expand All @@ -94,14 +92,14 @@ func convertConversation(conversation *entity.Conversation, err error) (*model.B
}

return &model.BertyEntityConversation{
ID: &conversation.ID,
ID: conversation.ID,
Title: &conversation.Title,
Topic: &conversation.Topic,
Members: members,
CreatedAt: &scalar.DateTime{Value: &conversation.CreatedAt},
UpdatedAt: &scalar.DateTime{Value: &conversation.UpdatedAt},
DeletedAt: &scalar.DateTime{Value: conversation.DeletedAt},
}, err
}
}

func convertUint32(value uint32) *int {
Expand All @@ -120,9 +118,9 @@ func convertBytes(value *[]byte) *string {
return &encoded
}

func convertEvent(event *p2p.Event, err error) (*model.BertyP2pEvent, error) {
func convertEvent(event *p2p.Event) *model.BertyP2pEvent {
if event == nil {
return &model.BertyP2pEvent{}, err
return &model.BertyP2pEvent{}
}

return &model.BertyP2pEvent{
Expand All @@ -141,7 +139,7 @@ func convertEvent(event *p2p.Event, err error) (*model.BertyP2pEvent, error) {
SentAt: &scalar.DateTime{Value: event.SentAt},
ReceivedAt: &scalar.DateTime{Value: event.ReceivedAt},
AckedAt: &scalar.DateTime{Value: event.AckedAt},
}, err
}
}

func convertEventKind(value p2p.Kind) *model.BertyP2pKind {
Expand Down

0 comments on commit f5ee4f1

Please sign in to comment.