Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
ce0a6f7
Basic progress
ayush3797 Nov 28, 2023
7c47ef5
adding createMultiple mutations
ayush3797 Nov 28, 2023
6677337
nits
ayush3797 Nov 28, 2023
5f3d45a
Collecting metadata about linking entities/adding flag to represent w…
ayush3797 Nov 30, 2023
03113c7
Generating object defs for directional linking entities
ayush3797 Dec 1, 2023
5256c01
clearing up logic
ayush3797 Dec 1, 2023
8793876
Adding prefix to linking fields
ayush3797 Dec 1, 2023
bc27394
Generating array input for *:N relationship
ayush3797 Dec 3, 2023
b047c9d
making nested entity optional
ayush3797 Dec 6, 2023
c5e6b06
updating mutation name
ayush3797 Dec 15, 2023
715125c
Handling conflicting column/relationship names with linking table
ayush3797 Dec 20, 2023
e6efb65
Adding method to get plural name
ayush3797 Dec 20, 2023
6af96e3
Updating logic/renaming variables
ayush3797 Jan 2, 2024
7a90f0b
shortening loop
ayush3797 Jan 3, 2024
4b91cc2
Solving bug for M:N relationship schema gen
ayush3797 Jan 13, 2024
191e257
nits
ayush3797 Jan 13, 2024
5f002ec
update branch
ayush3797 Jan 13, 2024
887dd79
format fix
ayush3797 Jan 14, 2024
82b0c7f
Fixing failures due to tests
ayush3797 Jan 15, 2024
33fca99
fixing format
ayush3797 Jan 15, 2024
2073c48
Moving linking entity logic to sqlmetadataprovider
ayush3797 Jan 15, 2024
2c96a8b
fixing typo
ayush3797 Jan 15, 2024
fe05132
Moving linking entity logic to sqlmdpvdr
ayush3797 Jan 16, 2024
11bb3d4
fixing format
ayush3797 Jan 16, 2024
d6f6949
fixing failures
ayush3797 Jan 16, 2024
1c0ce60
Preventing serialisation/deserialization of islinkingentity property
ayush3797 Jan 17, 2024
cba8072
Fixing dwsql
ayush3797 Jan 17, 2024
162f2de
god please fix this formatting error
ayush3797 Jan 17, 2024
e9d8b8e
fixing tests
ayush3797 Jan 17, 2024
c58f3ea
Refining logic to create linking objects
ayush3797 Jan 17, 2024
613f386
refining code
ayush3797 Jan 17, 2024
6757208
refactor schema converter for clear code
ayush3797 Jan 17, 2024
9e4b732
adding/removing comments
ayush3797 Jan 17, 2024
ff3e952
Merge with main
ayush3797 Jan 29, 2024
7a503d6
Addressing review
ayush3797 Feb 1, 2024
27a45c1
addressing review
ayush3797 Feb 1, 2024
baa0bb8
adding param name
ayush3797 Feb 2, 2024
f5237fe
Logic to find names of src/target entities from linking entity name
ayush3797 Feb 2, 2024
e963d40
update comment
ayush3797 Feb 2, 2024
af60e25
updating branch
ayush3797 Feb 6, 2024
09055ab
fixing bug
ayush3797 Feb 6, 2024
3b824d6
adding summary/reusing existing methods
ayush3797 Feb 12, 2024
29c2a1a
Initial progress
ayush3797 Feb 14, 2024
422630d
initial prgress
ayush3797 Feb 14, 2024
47def99
saving progress for fk directive
ayush3797 Feb 14, 2024
783464c
Logic to add FK directive for custom relationships
ayush3797 Feb 15, 2024
9cb61d6
Merge branch 'dev/agarwalayush/schemaGeneration' into dev/agarwalayus…
ayush3797 Feb 15, 2024
d68d311
separating naming logic for mutations
ayush3797 Feb 15, 2024
68b780c
Merge branch 'dev/agarwalayush/schemaGeneration' into dev/agarwalayus…
ayush3797 Feb 15, 2024
be7831f
making rel fields nullable
ayush3797 Feb 15, 2024
daeae37
Merge branch 'dev/agarwalayush/schemaGeneration' into dev/agarwalayus…
ayush3797 Feb 15, 2024
a5f3654
adding tests
ayush3797 Feb 15, 2024
b63aed6
nit
ayush3797 Feb 15, 2024
8583106
Merge branch 'dev/agarwalayush/schemaGeneration' into dev/agarwalayus…
ayush3797 Feb 15, 2024
5089f90
Adding test summaries
ayush3797 Feb 15, 2024
97e6878
refactoring test
ayush3797 Feb 15, 2024
d345a5f
updating comment
ayush3797 Feb 15, 2024
f4743de
updating branch
ayush3797 Feb 15, 2024
4c7cb74
Merge branch 'dev/agarwalayush/schemaGeneration' into dev/agarwalayus…
ayush3797 Feb 15, 2024
ce0c49f
Merge branch 'dev/NestedMutations' into dev/agarwalayush/schemaGenera…
ayush3797 Feb 15, 2024
ce8cc98
Adding test
ayush3797 Feb 15, 2024
7820551
Merge branch 'dev/agarwalayush/schemaGenerationTests' into dev/agarwa…
ayush3797 Feb 20, 2024
6b2f055
reverting conn string change
ayush3797 Feb 20, 2024
a9bb393
addressing review
ayush3797 Feb 22, 2024
be28782
addressing review
ayush3797 Feb 22, 2024
60ae0af
adding comment
ayush3797 Feb 22, 2024
55912f4
adding comment
ayush3797 Feb 22, 2024
effc380
addressing comments
ayush3797 Feb 27, 2024
adfcab9
updating mton function logic
ayush3797 Feb 27, 2024
9e377c3
refining logic
ayush3797 Feb 27, 2024
8db211c
addressing review
ayush3797 Feb 28, 2024
5ca4171
addressing review
ayush3797 Feb 28, 2024
a6ae8aa
Adding test asserting absence of ref field directive on non-ref columns
ayush3797 Feb 28, 2024
02c79bc
renaming set
ayush3797 Feb 29, 2024
7624675
formatting fix
ayush3797 Feb 29, 2024
559025f
formatting fix
ayush3797 Feb 29, 2024
78c8f7b
Merge branch 'dev/NestedMutations' into dev/agarwalayush/schemaGenera…
ayush3797 Feb 29, 2024
96c4a36
formatting fix
ayush3797 Feb 29, 2024
0c4fc3d
Refactoring cosmos create input generation into a different methof
ayush3797 Feb 29, 2024
fa9bcab
fixing test setup
ayush3797 Feb 29, 2024
f008c24
addressing review/adding comments
ayush3797 Mar 5, 2024
fac35d3
adding example
ayush3797 Mar 5, 2024
b34c9f1
Addressing review
ayush3797 Mar 13, 2024
cb7d185
removing stale logic code
ayush3797 Mar 13, 2024
09b8d98
Merge branch 'dev/NestedMutations' into dev/agarwalayush/schemaGenera…
ayush3797 Mar 21, 2024
75534f1
Merge branch 'dev/NestedMutations' into dev/agarwalayush/schemaGenera…
ayush3797 Mar 21, 2024
eb3238b
cleaning up test
ayush3797 Mar 21, 2024
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
2 changes: 2 additions & 0 deletions src/Cli.Tests/ModuleInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public static void Init()
VerifierSettings.IgnoreMember<RuntimeOptions>(options => options.IsCachingEnabled);
// Ignore the entity IsCachingEnabled as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<Entity>(entity => entity.IsCachingEnabled);
// Ignore the entity IsLinkingEntity as that's unimportant from a test standpoint.
VerifierSettings.IgnoreMember<Entity>(entity => entity.IsLinkingEntity);
// Ignore the UserProvidedTtlOptions. They aren't serialized to our config file, enforced by EntityCacheOptionsConverter.
VerifierSettings.IgnoreMember<EntityCacheOptions>(cacheOptions => cacheOptions.UserProvidedTtlOptions);
// Ignore the IsRequestBodyStrict as that's unimportant from a test standpoint.
Expand Down
7 changes: 6 additions & 1 deletion src/Config/ObjectModel/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public record Entity
public Dictionary<string, EntityRelationship>? Relationships { get; init; }
public EntityCacheOptions? Cache { get; init; }

[JsonIgnore]
public bool IsLinkingEntity { get; init; }

[JsonConstructor]
public Entity(
EntitySource Source,
Expand All @@ -40,7 +43,8 @@ public Entity(
EntityPermission[] Permissions,
Dictionary<string, string>? Mappings,
Dictionary<string, EntityRelationship>? Relationships,
EntityCacheOptions? Cache = null)
EntityCacheOptions? Cache = null,
bool IsLinkingEntity = false)
{
this.Source = Source;
this.GraphQL = GraphQL;
Expand All @@ -49,6 +53,7 @@ public Entity(
this.Mappings = Mappings;
this.Relationships = Relationships;
this.Cache = Cache;
this.IsLinkingEntity = IsLinkingEntity;
}

/// <summary>
Expand Down
23 changes: 19 additions & 4 deletions src/Core/Parsers/EdmModelBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,16 @@ private EdmModelBuilder BuildEntityTypes(ISqlMetadataProvider sqlMetadataProvide
// since we allow for aliases to be used in place of the names of the actual
// columns of the database object (such as table's columns), we need to
// account for these potential aliases in our EDM Model.
IReadOnlyDictionary<string, Entity> linkingEntities = sqlMetadataProvider.GetLinkingEntities();
foreach (KeyValuePair<string, DatabaseObject> entityAndDbObject in sqlMetadataProvider.GetEntityNamesAndDbObjects())
{
if (linkingEntities.ContainsKey(entityAndDbObject.Key))
{
// No need to create entity types for linking entity because the linking entity is not exposed for REST and GraphQL.
// Hence, there is no possibility of having a `filter` operation against it.
continue;
}

// Do not add stored procedures, which do not have table definitions or conventional columns, to edm model
// As of now, no ODataFilterParsing will be supported for stored procedure result sets
if (entityAndDbObject.Value.SourceType is not EntitySourceType.StoredProcedure)
Expand Down Expand Up @@ -109,12 +117,19 @@ private EdmModelBuilder BuildEntitySets(ISqlMetadataProvider sqlMetadataProvider

// Entity set is a collection of the same entity, if we think of an entity as a row of data
// that has a key, then an entity set can be thought of as a table made up of those rows.
foreach (KeyValuePair<string, DatabaseObject> entityAndDbObject in sqlMetadataProvider.GetEntityNamesAndDbObjects())
IReadOnlyDictionary<string, Entity> linkingEntities = sqlMetadataProvider.GetLinkingEntities();
foreach ((string entityName, DatabaseObject dbObject) in sqlMetadataProvider.GetEntityNamesAndDbObjects())
{
if (entityAndDbObject.Value.SourceType != EntitySourceType.StoredProcedure)
if (linkingEntities.ContainsKey(entityName))
{
// No need to create entity set for linking entity.
continue;
}

if (dbObject.SourceType != EntitySourceType.StoredProcedure)
{
string entityName = $"{entityAndDbObject.Value.FullName}";
container.AddEntitySet(name: $"{entityAndDbObject.Key}.{entityName}", _entities[$"{entityAndDbObject.Key}.{entityName}"]);
string fullSourceName = $"{dbObject.FullName}";
container.AddEntitySet(name: $"{entityName}.{fullSourceName}", _entities[$"{entityName}.{fullSourceName}"]);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/Core/Resolvers/CosmosMutationEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void AuthorizeMutationFields(
List<string> inputArgumentKeys;
if (mutationOperation != EntityActionOperation.Delete)
{
inputArgumentKeys = BaseSqlQueryStructure.GetSubArgumentNamesFromGQLMutArguments(MutationBuilder.INPUT_ARGUMENT_NAME, parameters);
inputArgumentKeys = BaseSqlQueryStructure.GetSubArgumentNamesFromGQLMutArguments(MutationBuilder.ITEM_INPUT_ARGUMENT_NAME, parameters);
}
else
{
Expand Down Expand Up @@ -165,7 +165,7 @@ private static async Task<ItemResponse<JObject>> HandleDeleteAsync(IDictionary<s

private static async Task<ItemResponse<JObject>> HandleCreateAsync(IDictionary<string, object?> queryArgs, Container container)
{
object? item = queryArgs[CreateMutationBuilder.INPUT_ARGUMENT_NAME];
object? item = queryArgs[MutationBuilder.ITEM_INPUT_ARGUMENT_NAME];

JObject? input;
// Variables were provided to the mutation
Expand Down Expand Up @@ -212,7 +212,7 @@ private static async Task<ItemResponse<JObject>> HandleUpdateAsync(IDictionary<s
throw new InvalidDataException("Partition Key field is mandatory");
}

object? item = queryArgs[CreateMutationBuilder.INPUT_ARGUMENT_NAME];
object? item = queryArgs[MutationBuilder.ITEM_INPUT_ARGUMENT_NAME];

JObject? input;
// Variables were provided to the mutation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ HttpContext httpContext
sqlMetadataProvider,
authorizationResolver,
gQLFilterParser,
GQLMutArgumentToDictParams(context, CreateMutationBuilder.INPUT_ARGUMENT_NAME, mutationParams),
GQLMutArgumentToDictParams(context, MutationBuilder.ITEM_INPUT_ARGUMENT_NAME, mutationParams),
httpContext)
{ }

Expand Down
2 changes: 1 addition & 1 deletion src/Core/Resolvers/SqlMutationEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ public void AuthorizeMutationFields(
List<string> inputArgumentKeys;
if (mutationOperation != EntityActionOperation.Delete)
{
inputArgumentKeys = BaseSqlQueryStructure.GetSubArgumentNamesFromGQLMutArguments(MutationBuilder.INPUT_ARGUMENT_NAME, parameters);
inputArgumentKeys = BaseSqlQueryStructure.GetSubArgumentNamesFromGQLMutArguments(MutationBuilder.ITEM_INPUT_ARGUMENT_NAME, parameters);
}
else
{
Expand Down
Loading