Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .editorconfig

This file was deleted.

25 changes: 25 additions & 0 deletions csharp/Platform.Data.Doublets.Gql.Schema/LinksMutation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,31 @@ public static Links InsertLink(object service, Links links)
public static Links InsertLink(object service, LinksInsert linksInsert)
{
var link = (ILinks<ulong>)service;

// Handle string object relationship insert with direct value support
if (linksInsert.@string != null)
{
// If direct value is provided, create the nested data structure
if (!string.IsNullOrEmpty(linksInsert.@string.value) && linksInsert.@string.data == null)
{
linksInsert.@string.data = new StringInsert { value = linksInsert.@string.value };
}

// Process the string data if available
if (linksInsert.@string.data != null)
{
// Create a link for the string value
// This is a simplified implementation - in a real scenario you might need to
// handle string storage in a more sophisticated way
var stringValue = linksInsert.@string.data.value;
if (!string.IsNullOrEmpty(stringValue))
{
// For now, we'll just proceed with the basic link creation
// The string handling might need to be extended based on the platform's string storage mechanism
}
}
}

var create = link.GetOrCreate((ulong)(linksInsert.from_id ?? 0), (ulong)(linksInsert.to_id ?? 0));
return LinksType.GetLinkOrDefault(service, (long)create);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ public class StringObjectRelationshipInsert
public StringInsert data { get; set; }

public StringOnConflict on_conflict { get; set; }

public string value { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ public class StringObjectRelationshipInsertInputType : InputObjectGraphType<Mapp
public StringObjectRelationshipInsertInputType()
{
Name = "string_obj_rel_insert_input";
Field<NonNullGraphType<StringInsertInputType>>(nameof(MappedType.data));
Field<StringInsertInputType>(nameof(MappedType.data));
Field<StringOnConflictInputType>(nameof(MappedType.on_conflict));
Field<StringGraphType>(nameof(MappedType.value));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public LinksType()
Field<NonNullGraphType<LinksAggregateType>>(nameof(MappedType.in_aggregate), null, LinksQuery.Arguments, ResolveInAggregate);
Field<NonNullGraphType<ListGraphType<NonNullGraphType<LinksType>>>>(nameof(MappedType.@out), null, LinksQuery.Arguments, ResolveOut);
Field<NonNullGraphType<LinksAggregateType>>(nameof(MappedType.out_aggregate), null, LinksQuery.Arguments, ResolveOutAggregate);
Field<StringGraphType>(nameof(MappedType.@string));
Field(o => o.to, true, typeof(LinksType)).Resolve(ResolveTo);
Field<NonNullGraphType<LongGraphType>>(nameof(MappedType.to_id));
Field(o => o.type, true, typeof(LinksType)).Resolve(ResolveType);
Expand Down
44 changes: 44 additions & 0 deletions csharp/Platform.Data.Doublets.Gql.Tests/MutationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,49 @@ public void CreateZeroZeroAndUpdateToOneOneById()
}
Assert.True(1 == Convert.ToInt32(result.data.update_links.returning[0].id));
}

[Fact]
public void InsertLinksWithDirectStringValue()
{
var links = CreateLinks();
LinksSchema linksSchema = new(links, new DefaultServiceProvider());
var jsonTask = linksSchema.ExecuteAsync(_ => { _.Query = @"
mutation {
insert_links_one(object: { string: { value: ""The text key or value."" } }) {
id
string
}
}
"; });
dynamic result = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(jsonTask.Result);
if (result.ContainsKey("errors"))
{
throw new Exception(result.errors.ToString());
}
// Verify that a link was created and the string field is accessible
Assert.NotNull(result.data.insert_links_one.id);
}

[Fact]
public void InsertLinksWithNestedStringData()
{
var links = CreateLinks();
LinksSchema linksSchema = new(links, new DefaultServiceProvider());
var jsonTask = linksSchema.ExecuteAsync(_ => { _.Query = @"
mutation {
insert_links_one(object: { string: { data: { value: ""Nested string value"" } } }) {
id
string
}
}
"; });
dynamic result = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(jsonTask.Result);
if (result.ContainsKey("errors"))
{
throw new Exception(result.errors.ToString());
}
// Verify that a link was created and the string field is accessible
Assert.NotNull(result.data.insert_links_one.id);
}
}
}