Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 50cc2cc

Browse files
Merge branch 'feature/umbraco-forms' into develop
2 parents 6cf560e + 8dcaf82 commit 50cc2cc

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

‎Our.Umbraco.GraphQL.Forms/Types/UmbracoFormsMutation.cs‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Newtonsoft.Json.Linq;
33
using Our.Umbraco.GraphQL.Adapters.Types;
44
using Our.Umbraco.GraphQL.Attributes;
5+
using Our.Umbraco.GraphQL.Types;
56
using System;
67
using System.Collections.Generic;
78
using System.IO;
@@ -36,8 +37,8 @@ public UmbracoFormsMutation(ILogger logger, IFormStorage formStorage, IFieldType
3637

3738
Field<JsonGraphType>()
3839
.Name("submit")
39-
.Argument<StringGraphType>("formId", "The GUID of the form")
40-
.Argument<IntGraphType>("umbracoPageId", "The integer ID of the Umbraco page you were on")
40+
.Argument<NonNullGraphType<StringGraphType>>("formId", "The GUID of the form")
41+
.Argument<NonNullGraphType<Adapters.Types.IdGraphType>>("umbracoPageId", "The integer ID of the Umbraco page you were on")
4142
.Argument<ListGraphType<FieldValueInputType>>("fields", "An array of objects representing the field data. Each object has a 'field' property that is either the GUID or alias of the form field, and a 'value' property that is the field value")
4243
.Resolve(Submit);
4344
_logger = logger;
@@ -51,12 +52,12 @@ public UmbracoFormsMutation(ILogger logger, IFormStorage formStorage, IFieldType
5152
private object Submit(ResolveFieldContext<object> ctx)
5253
{
5354
string formIdArg = null;
54-
int umbracoPageId = 0;
55+
Id umbracoPageId = null;
5556

5657
try
5758
{
5859
formIdArg = ctx.GetArgument<string>("formId");
59-
umbracoPageId = ctx.GetArgument<int>("umbracoPageId");
60+
umbracoPageId = ctx.GetArgument<Id>("umbracoPageId");
6061
var fieldsList = ctx.GetArgument<List<FieldValue>>("fields");
6162

6263
if (!Guid.TryParse(formIdArg, out var formId) || !(_formStorage.GetForm(formId) is Form form)) return SubmitResult("The form ID specified could not be found");
@@ -73,7 +74,9 @@ private object Submit(ResolveFieldContext<object> ctx)
7374
using (var ucRef = _umbracoContextFactory.EnsureUmbracoContext(contextWrapped))
7475
{
7576
var uc = ucRef.UmbracoContext;
76-
var page = uc.Content.GetById(umbracoPageId);
77+
var page = Guid.TryParse(umbracoPageId.Value, out var guid) ? uc.Content.GetById(guid)
78+
: (int.TryParse(umbracoPageId.Value, out var id) ? uc.Content.GetById(id)
79+
: (GuidUdi.TryParse(umbracoPageId.Value, out var udi) ? uc.Content.GetById(udi.Guid) : null));
7780
if (page == null) return SubmitResult("Could not find the umbracoPageId specified");
7881

7982
var url = page.Url;
@@ -83,7 +86,7 @@ private object Submit(ResolveFieldContext<object> ctx)
8386
uc.PublishedRequest = request;
8487
_publishedRouter.PrepareRequest(request);
8588

86-
var recordId = SubmitForm(context, contextWrapped, formId, form, umbracoPageId, fields);
89+
var recordId = SubmitForm(context, contextWrapped, formId, form, page.Id, fields);
8790
return SubmitResult(recordId);
8891
}
8992
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /