-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial mutation with
LessonSave
- Loading branch information
Alex Damian Negru
committed
Jun 26, 2021
1 parent
27f576d
commit dd80e90
Showing
7 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using GraphQL.Types; | ||
|
||
namespace TeacherWorkout.Api.GraphQL.Inputs | ||
{ | ||
public class LessonSaveInput : InputObjectGraphType | ||
{ | ||
public LessonSaveInput() | ||
{ | ||
Name = "LessonSaveInput"; | ||
Field<IdGraphType>("lessonId"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using GraphQL; | ||
using GraphQL.Types; | ||
using TeacherWorkout.Api.GraphQL.Types; | ||
using TeacherWorkout.Api.Models; | ||
using LessonSaveInput = TeacherWorkout.Api.GraphQL.Inputs.LessonSaveInput; | ||
|
||
namespace TeacherWorkout.Api.GraphQL | ||
{ | ||
public class TeacherWorkoutMutation : ObjectGraphType<object> | ||
{ | ||
public TeacherWorkoutMutation(LessonSaveInput input) | ||
{ | ||
Name = "Mutation"; | ||
|
||
Field<LessonSavePayloadType>( | ||
"lessonSave", | ||
arguments: new QueryArguments( | ||
new QueryArgument<NonNullGraphType<LessonSaveInput>> {Name = "input"} | ||
), | ||
resolve: context => new LessonSavePayload | ||
{ | ||
Lesson = new Lesson | ||
{ | ||
Id = "42", | ||
Title = "Lorem Ipsum", | ||
Thumbnail = new Image | ||
{ | ||
Description = "For Challenged People", | ||
Url = "https://example.com" | ||
}, | ||
Theme = new Theme | ||
{ | ||
Id = "1", | ||
Title = "Lorem Ipsum", | ||
Thumbnail = new Image | ||
{ | ||
Description = "For Challenged People", | ||
Url = "https://example.com" | ||
} | ||
}, | ||
Duration = new Duration | ||
{ | ||
Value = 45, | ||
Unit = DurationUnit.Minutes | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using GraphQL.Types; | ||
using TeacherWorkout.Api.Models; | ||
|
||
namespace TeacherWorkout.Api.GraphQL.Types | ||
{ | ||
public class LessonSavePayloadType : ObjectGraphType<LessonSavePayload> | ||
{ | ||
public LessonSavePayloadType() | ||
{ | ||
Name = "LessonSavePayload"; | ||
|
||
Field(x => x.Lesson).Description("The newly created lesson."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using TeacherWorkout.Api.GraphQL.Types; | ||
|
||
namespace TeacherWorkout.Api.Models | ||
{ | ||
public class LessonSavePayload | ||
{ | ||
public Lesson Lesson { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
|
||
<ItemGroup> | ||
<Folder Include="Controllers" /> | ||
<Folder Include="GraphQL\Mutations" /> | ||
</ItemGroup> | ||
|
||
</Project> |