Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CreateEventField = &graphql.Field{ Type: types.EventType, Description: "Create new event", Args: graphql.FieldConfigArgument{ "user": &graphql.ArgumentConfig{ Type: types.UserInput, }, "eventName": &graphql.ArgumentConfig{ Type: graphql.NewNonNull(graphql.String), }, "description": &graphql.ArgumentConfig{ Type: graphql.NewNonNull(graphql.String), }, "location": &graphql.ArgumentConfig{ Type: graphql.NewNonNull(graphql.String), }, "startTime": &graphql.ArgumentConfig{ Type: graphql.NewNonNull(graphql.String), }, "endTime": &graphql.ArgumentConfig{ Type: graphql.NewNonNull(graphql.String), }, }, Resolve: func(params graphql.ResolveParams) (interface{}, error) { givenUser, _ := params.Args["user"] eventName, _ := params.Args["eventName"].(string) description, _ := params.Args["description"].(string) location, _ := params.Args["location"].(string) startTime, _ := params.Args["startTime"].(string) endTime, _ := params.Args["endTime"].(string) parsedJson, err := json.Marshal(givenUser) if err != nil { panic(err) } var parsedUser user.User err = json.Unmarshal(parsedJson, &parsedUser) if err != nil { panic(err) } newEvent, err := event.NewEvent(&parsedUser, eventName, description, location, startTime, endTime) if err != nil { panic(err) } infrastructure.NewEventRepository().Store(newEvent) return newEvent, nil }, }
create event
View Source
var CreateUserField = &graphql.Field{ Type: types.UserType, Description: "Create new user", Args: graphql.FieldConfigArgument{ "userName": &graphql.ArgumentConfig{ Type: graphql.NewNonNull(graphql.String), }, "description": &graphql.ArgumentConfig{ Type: graphql.NewNonNull(graphql.String), }, "photoURL": &graphql.ArgumentConfig{ Type: graphql.NewNonNull(graphql.String), }, "email": &graphql.ArgumentConfig{ Type: graphql.NewNonNull(graphql.String), }, }, Resolve: func(params graphql.ResolveParams) (interface{}, error) { userName, _ := params.Args["userName"].(string) description, _ := params.Args["description"].(string) photoURL, _ := params.Args["photoURL"].(string) email, _ := params.Args["email"].(string) newUser, err := user.NewUser(userName, description, photoURL, email) if err != nil { panic(err) } infrastructure.NewUserRepository().Store(newUser) return newUser, nil }, }
create user
View Source
var EventField = &graphql.Field{ Type: types.EventType, Description: "Get single event", Args: graphql.FieldConfigArgument{ "id": &graphql.ArgumentConfig{ Type: graphql.String, }, }, Resolve: func(params graphql.ResolveParams) (interface{}, error) { eventId, isOK := params.Args["id"].(string) if isOK { return service.FindEventById(eventId) } return nil, errors.New("no eventId") }, }
fetch single event
View Source
var EventListField = &graphql.Field{ Type: graphql.NewList(types.EventType), Description: "List of events", Resolve: func(p graphql.ResolveParams) (interface{}, error) { return infrastructure.NewEventRepository().EventList(), nil }, }
fetch all event
View Source
var UserField = &graphql.Field{ Type: types.UserType, Description: "Get single user", Args: graphql.FieldConfigArgument{ "id": &graphql.ArgumentConfig{ Type: graphql.String, }, }, Resolve: func(params graphql.ResolveParams) (interface{}, error) { userId, isOK := params.Args["id"].(string) if isOK { return service.FindUserById(userId) } return nil, errors.New("no userId") }, }
fetch single user
View Source
var UserListField = &graphql.Field{ Type: graphql.NewList(types.UserType), Description: "List of users", Resolve: func(p graphql.ResolveParams) (interface{}, error) { return infrastructure.NewUserRepository().UserList(), nil }, }
fetch all user
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.