Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
213 commits
Select commit Hold shift + click to select a range
44f5028
quick go at generating a schema from the provided types
aaronpowell Feb 21, 2022
a1dbc7c
Merge branch 'main' into dev/aaronpowell/graphql-schema-generation
aaronpowell Mar 1, 2022
f32a358
moving the schema builder out to a new project
aaronpowell Mar 1, 2022
f71a972
following the naming conventions
aaronpowell Mar 1, 2022
cf5bfb5
starting tests for query builder
aaronpowell Mar 1, 2022
698356c
fixing some formatting issues
aaronpowell Mar 1, 2022
3f80fa9
getting the docker build working again
aaronpowell Mar 1, 2022
2d57039
more whitespace fixes
aaronpowell Mar 1, 2022
8c872a5
whitespace yet again
aaronpowell Mar 1, 2022
f852aa1
started some mutation tests
aaronpowell Mar 1, 2022
05e14b3
initial pass at filter input generation
aaronpowell Mar 2, 2022
dabbfc5
Merge branch 'main' into dev/aaronpowell/graphql-schema-generation
aaronpowell Mar 3, 2022
581018c
whitespace corrections
aaronpowell Mar 3, 2022
060daf2
missing auth from builder
aaronpowell Mar 9, 2022
8f4030b
Merge remote-tracking branch 'origin/main' into dev/aaronpowell/graph…
aaronpowell Mar 9, 2022
c731874
removing a try/catch from earlier testing
aaronpowell Mar 9, 2022
4a05366
labeling nulls to make their usage obvious and another test
aaronpowell Mar 9, 2022
9613e44
minor whitespace issue
aaronpowell Mar 9, 2022
d2bcf89
Merge branch 'main' into dev/aaronpowell/graphql-schema-generation
aaronpowell Mar 10, 2022
87c5ace
adding a method to handle query naming conventions
aaronpowell Mar 10, 2022
8a5ee30
Merge branch 'dev/aaronpowell/graphql-schema-generation' of https://g…
aaronpowell Mar 10, 2022
81d7e85
Getting the CosmosDB query tests working with the newly generated gra…
aaronpowell Mar 10, 2022
3d14122
formatting
aaronpowell Mar 10, 2022
3b9a14c
fixing query builder tests
aaronpowell Mar 10, 2022
0707385
Merge branch 'main' into dev/aaronpowell/graphql-schema-generation
aaronpowell Mar 14, 2022
a500c69
Starting work on SQL tests against the generated GraphQL queries
aaronpowell Mar 15, 2022
c09fa70
adding AND and OR support to the builder
aaronpowell Mar 15, 2022
61c6663
adding the delete mutation builder and tests
aaronpowell Mar 15, 2022
c9c2053
Update mutation builder implemented
aaronpowell Mar 15, 2022
aac8f62
Merge branch 'main' of https://github.com/Azure/hawaii-gql into dev/a…
aaronpowell Mar 21, 2022
da0a478
fixing build error
aaronpowell Mar 21, 2022
f80cb4a
fixing query tests
aaronpowell Mar 21, 2022
ad1e0e9
overhaul of mutation tests to use input types and the GraphQL request…
aaronpowell Mar 22, 2022
d20f707
having branches depending on what kind of DB engine we're generating for
aaronpowell Mar 23, 2022
bb19fca
Using HotChocolate's built-in query parser
aaronpowell Mar 23, 2022
1e676e4
Merge branch 'aaronpowell/graphql-parsing-improvements' into dev/aaro…
aaronpowell Mar 23, 2022
d0350bd
handling GraphQL input types for the cosmosdb mutation queries
aaronpowell Mar 28, 2022
b3c88d4
starting to fix the mssql query tests with input types
aaronpowell Mar 28, 2022
7e9e2be
proper structure of query
aaronpowell Mar 28, 2022
85aadde
Merge branch 'main' into dev/aaronpowell/graphql-schema-generation
aaronpowell Mar 28, 2022
9af9113
fixing query structure for some mysql and postgresql tests
aaronpowell Mar 28, 2022
07f40d5
fixing compile error
aaronpowell Mar 28, 2022
0703bab
Avoiding adding model types to create/update Input type that's generated
aaronpowell Mar 28, 2022
8a25fdb
Changing SQL insert to handle input parameter rather than inline fiel…
aaronpowell Mar 28, 2022
d869918
Adding a test for insert with variables
aaronpowell Mar 28, 2022
f056395
updating tests on other sql forms
aaronpowell Mar 28, 2022
a23cf8c
Adding support for input args on update mutations
aaronpowell Mar 28, 2022
4905bcd
forgot to include the JSON config
aaronpowell Mar 28, 2022
c1b31e2
updating tests across all sql engines
aaronpowell Mar 28, 2022
361656d
removing unneeded using
aaronpowell Mar 28, 2022
a813b29
bit of improvement in the config checking using consts rather than ma…
aaronpowell Mar 28, 2022
8120add
formatting fix
aaronpowell Mar 28, 2022
740fc16
supporting when you don't have the item field in the params
aaronpowell Mar 28, 2022
67c327b
fixing pagination tests
aaronpowell Mar 28, 2022
cd49857
cleaning up the query tests a bit
aaronpowell Mar 28, 2022
823340b
Merge remote-tracking branch 'origin/main' into dev/aaronpowell/graph…
aaronpowell Apr 1, 2022
454757a
reverting name of continuation token to endCursor, which matches more…
aaronpowell Apr 1, 2022
854b761
Merge branch 'main' into dev/aaronpowell/graphql-schema-generation
aaronpowell Apr 4, 2022
006bff8
Merge branch 'main' into dev/aaronpowell/graphql-schema-generation
aaronpowell Apr 19, 2022
8a35249
Merge branch 'main' into dev/aaronpowell/graphql-schema-generation
aaronpowell Apr 20, 2022
d9e2070
Fixing compiler error from bad merge
aaronpowell Apr 20, 2022
3b7c79a
Merge branch 'main' into dev/aaronpowell/graphql-schema-generation
aaronpowell Apr 21, 2022
c3b1e4c
starting to incorporate the new schema config in the GraphQL object b…
aaronpowell Apr 25, 2022
77d6d08
Code cleanup
aaronpowell Apr 25, 2022
43bca3b
small whitespace change
aaronpowell Apr 26, 2022
bd3fe75
trying to fix formatting still
aaronpowell Apr 26, 2022
3ad3a31
adding comment to why tests are diabled
aaronpowell Apr 26, 2022
1380816
Trying to force line endings
aaronpowell Apr 26, 2022
54e827b
un-breaking the line endings
aaronpowell Apr 26, 2022
4ec3391
Merge branch 'main' into dev/aaronpowell/graphql-schema-generation
aaronpowell Apr 26, 2022
1e1a31c
Merge branch 'dev/aaronpowell/graphql-object-builder' into merge-sql-…
aaronpowell Apr 26, 2022
ee77c0e
Fix formatting
Aniruddh25 Apr 26, 2022
97020a8
Fixing broken test from bad copy/paste
aaronpowell Apr 26, 2022
19cf1d8
Merge branch 'dev/aaronpowell/graphql-object-builder' into merge-sql-…
aaronpowell Apr 26, 2022
572864e
incorporating the SQL object builder into the GraphQL schema pipeline
aaronpowell Apr 26, 2022
dbf8378
Merge branch 'main' into dev/aaronpowell/graphql-schema-generation
aaronpowell Apr 28, 2022
2c51a7a
working on integration of runtime config with schema builder
aaronpowell Apr 28, 2022
9c939c9
rollback of the endCursor to after as field name
aaronpowell Apr 26, 2022
e0e9814
WIP
aaronpowell Apr 27, 2022
b6e4437
Block access to Post on Configuration controller if runtime is alread…
Mathos1432 Apr 27, 2022
0b2fbc6
Create `RuntimeConfigProvider` to consume `runtime-config.json` and r…
Aniruddh25 Apr 28, 2022
3f5e775
handling when someone disables a relationship in the runtime config
aaronpowell Apr 27, 2022
a2f5fe8
making the code clearer
aaronpowell Apr 27, 2022
de226d0
Fixing test name
aaronpowell Apr 27, 2022
b4d7054
Using config entity to get the naming conventions with overrides
aaronpowell Apr 27, 2022
8902c87
Adding pluralization rules using Humanizer plus tests
aaronpowell Apr 27, 2022
2b2f31f
changing how we identify relationships for a foreign key
aaronpowell Apr 28, 2022
c559261
Fixing compile errors across the GraphQL type builder
aaronpowell Apr 28, 2022
9b7a586
refactoring unit tests to work with runtime config
aaronpowell Apr 28, 2022
5435c85
getting the CosmosDB tests working again
aaronpowell Apr 28, 2022
0e8a007
WIP
aaronpowell Apr 28, 2022
dcd9fe5
Merge branch 'main' into dev/aaronpowell/graphql-schema-generation
aaronpowell Apr 29, 2022
cbe89b5
Starting work on building full schema with object models
aaronpowell Apr 29, 2022
c436e0c
Building the GraphQL schema with inputs and connections
aaronpowell Apr 29, 2022
18d19e6
disabling the schema builder in the engine
aaronpowell Apr 29, 2022
26e6123
formatting fixes
aaronpowell Apr 29, 2022
ebcc612
restoring old GraphQL schema for tests
aaronpowell Apr 29, 2022
ec74eb1
Initialize the GraphQL schema fully
aaronpowell Apr 29, 2022
fc37082
reverting the tests to use the old schema structure
aaronpowell Apr 29, 2022
b62ff09
reverting more files
aaronpowell Apr 29, 2022
5924a06
Ensure constant default value insertion through graphQL mutation; fix…
abhishekkumams May 3, 2022
0c700de
added a .Name to the restvery to string so naming matches with reques…
aaronburtle May 6, 2022
f0b60fd
OrderBy Support for GQL ++ (#379)
gledis69 May 6, 2022
7bdb767
Patch #379 since the config was not valid (#391)
gledis69 May 6, 2022
6c3f5ea
Generating a full GraphQL schema from data models (#250)
aaronpowell May 9, 2022
5872c5c
updating the cosmos tests to use the new schema
aaronpowell May 9, 2022
5d6cae2
importing partially updated sql test
aaronpowell May 10, 2022
a7670a2
removing legacy schema generator
aaronpowell May 10, 2022
4ed9b95
Merge branch 'main' into dev/aaronpowell/graphql-schema-generation-in…
aaronpowell May 10, 2022
c16cf18
not needed in DI anymore
aaronpowell May 10, 2022
fbd312b
Merge origin/main
Aniruddh25 May 11, 2022
1d2beb4
Fix bad merge
Aniruddh25 May 12, 2022
201e3fa
Remove sql-config.json altogether
Aniruddh25 May 12, 2022
a24728b
Comment the relationship subquery part
Aniruddh25 May 12, 2022
bb58faf
Fix formatting
Aniruddh25 May 12, 2022
eb1a99d
Fix comma typo
Aniruddh25 May 12, 2022
ca61b0d
Remove some unneeded validations
Aniruddh25 May 12, 2022
1e648bc
Resolver config file only for cosmos db
Aniruddh25 May 12, 2022
e2cfcaf
Remove dependency on GraphQLFileMetadataProvider for SQL
Aniruddh25 May 12, 2022
5ae3fd6
Remove need for graphql metadata provider when invoked for sql
Aniruddh25 May 12, 2022
2b403c4
No need of resolver config file
Aniruddh25 May 12, 2022
36a67f3
ResolverConfigFile is only a cosmos db option
Aniruddh25 May 12, 2022
166b2d3
Remove the unnecessary validations - since we generate the gql schema…
Aniruddh25 May 12, 2022
729595d
Fix resolver config
Aniruddh25 May 12, 2022
f7a3b42
Remove additional validator exceptions
Aniruddh25 May 12, 2022
8de904a
Fix typo
Aniruddh25 May 12, 2022
d836192
Remove the old config file validator
Aniruddh25 May 12, 2022
0385b7d
Fix formatting
Aniruddh25 May 12, 2022
c416fea
Add RuntimeConfigValidation test
Aniruddh25 May 12, 2022
fe55389
GraphqlFileMetadataProvider is nullable for GraphQLService
Aniruddh25 May 12, 2022
6233679
Fix publisher entity name
Aniruddh25 May 12, 2022
066c114
Handle relationships
Aniruddh25 May 13, 2022
912a5a6
Infer foreign key only if needed
Aniruddh25 May 14, 2022
91778a6
Fix SqlQueryStructure to add the correct predicates based on foreign …
Aniruddh25 May 14, 2022
18fb067
Testing Relationship querying
Aniruddh25 May 14, 2022
519931f
Fix formatting
Aniruddh25 May 14, 2022
f5b3da1
Case insensitive comparison so that Graphql entity names match
Aniruddh25 May 14, 2022
63fe979
Fix bugs
Aniruddh25 May 14, 2022
10fafe2
AddJoinPredicatesForSubQuery
Aniruddh25 May 14, 2022
24eb8e7
Move protected functions together
Aniruddh25 May 15, 2022
2305055
Adding isNull field to standard inputs
aaronpowell May 13, 2022
6bb749a
Fix SchemaConverter tests
Aniruddh25 May 15, 2022
99b9d68
Fix GQLFilter tests
Aniruddh25 May 15, 2022
9a7e44c
Primary fields can be composite
Aniruddh25 May 15, 2022
dc70491
Fix additional mssql tests
Aniruddh25 May 15, 2022
f4ad5a4
Fix reading large JSON result bug on single item Execute
Aniruddh25 May 15, 2022
7182529
Fix tests
Aniruddh25 May 15, 2022
1817451
Fix pagination tests
Aniruddh25 May 15, 2022
2849c87
Fix pagination token argument and field name
Aniruddh25 May 15, 2022
0364eea
Fix GQL Mutations
Aniruddh25 May 15, 2022
89e0dbc
Fix UpdateMutation
Aniruddh25 May 15, 2022
000b50b
Fix target entityname
Aniruddh25 May 15, 2022
fe72afe
Fix formatting
Aniruddh25 May 15, 2022
24dcfad
Fix graphql paginated mutation and 1 more list query
Aniruddh25 May 15, 2022
c828a9d
Keep upper casing of environment file as of now
Aniruddh25 May 15, 2022
b8adb96
Merge with schema name support
Aniruddh25 May 15, 2022
b3dee0c
Fix test build errors
Aniruddh25 May 15, 2022
4ed3d19
Fix SchemaName build issues
Aniruddh25 May 15, 2022
7955de1
Fix formatting
Aniruddh25 May 15, 2022
9e5e0be
Remove schema name nullability
Aniruddh25 May 15, 2022
f40dbb8
Fix incorrect merge
Aniruddh25 May 15, 2022
48f5127
Fix entity names in GraphQL tests
Aniruddh25 May 15, 2022
acb9163
Fix runtime config relationships section
Aniruddh25 May 15, 2022
c29910f
Fix mutation schema generator tests for Cosmos
Aniruddh25 May 15, 2022
b288553
reset unecessary change
Aniruddh25 May 15, 2022
ad6b4a3
add new line
Aniruddh25 May 15, 2022
c7d5514
Fix how to obtain mutation operation name
Aniruddh25 May 15, 2022
cb2939f
Remove left over Exceptions folder
Aniruddh25 May 15, 2022
acb548c
fix Cosmos tests to conform to autogen schema
Aniruddh25 May 15, 2022
8179ba2
Fix Cosmos tests
Aniruddh25 May 16, 2022
81f812e
Add GraphQLMutationTestBase
Aniruddh25 May 16, 2022
855cd34
Fix formatting
Aniruddh25 May 16, 2022
ec04f76
Remove irrelevant query tests
Aniruddh25 May 16, 2022
049acb4
GraphqlMetadataProvider is required for cosmos
Aniruddh25 May 16, 2022
85b7790
Refactor Sql mutation tests
Aniruddh25 May 16, 2022
766d3c3
git hook Fix formatting
Aniruddh25 May 16, 2022
fc269b3
Fix PostgreSql mutation tests
Aniruddh25 May 16, 2022
41652b8
Remove unnecessary using
Aniruddh25 May 16, 2022
4e9b551
Separate out Pagination Token Argument and Field Name
Aniruddh25 May 16, 2022
b0c7aa0
Assert Total item count retrieved in paginated query without variables
Aniruddh25 May 16, 2022
47c6a74
Add GraphQLQueryTestBase
Aniruddh25 May 16, 2022
a7808b6
Remove unnecessary using
Aniruddh25 May 16, 2022
2b52779
Derive PostgreSqlGraphQLQuery from GraphQLQueryTestBase
Aniruddh25 May 16, 2022
bf8d398
Remove unnecessary using
Aniruddh25 May 16, 2022
9c46c92
Merge remote-tracking branch 'origin/main' into dev/anmunde/graphql-s…
Aniruddh25 May 16, 2022
c91ebcb
Fix MySqlGraphQLQueryTests
Aniruddh25 May 16, 2022
d1e631f
Fix formatting
Aniruddh25 May 16, 2022
e419b67
Fix mysql config
Aniruddh25 May 16, 2022
15e874b
Fix the default config
Aniruddh25 May 16, 2022
10bdce6
Fix PostgreSql tests
Aniruddh25 May 16, 2022
2b289d3
Add QuoteIdentifier to interface and fix mysql foreign key query
Aniruddh25 May 17, 2022
95fae9a
Fix formatting
Aniruddh25 May 17, 2022
968d72d
Fix MySqlMutation test
Aniruddh25 May 17, 2022
7dcd01f
Fix stack overflow in test due to calling itself
Aniruddh25 May 17, 2022
c507dc7
Fix OneToOneJoin query for MySql
Aniruddh25 May 17, 2022
4d83e08
Fix the field name for website placement
Aniruddh25 May 17, 2022
6a8f465
Fix column name occurrences
Aniruddh25 May 17, 2022
6eaf5ed
Fix more field names
Aniruddh25 May 17, 2022
b2a9a4d
Update DataGateway.Service.GraphQLBuilder/Mutations/DeleteMutationBui…
Aniruddh25 May 17, 2022
708c743
Update DataGateway.Service.GraphQLBuilder/Mutations/MutationBuilder.cs
Aniruddh25 May 17, 2022
53ca241
Use private sets
Aniruddh25 May 17, 2022
f4f6bc9
Merge branch 'dev/anmunde/graphql-schema-generation-integration' of h…
Aniruddh25 May 17, 2022
ef947fb
Fix formatting
Aniruddh25 May 17, 2022
91c2ff5
Removed old code and added Datagateway exception
Aniruddh25 May 17, 2022
0ef523a
Fix Enum to string
Aniruddh25 May 17, 2022
4c9817f
IgnoreCase while determining MutationOperation
Aniruddh25 May 17, 2022
bc1cb66
Return a single JSON object for OnetoOneJoinQuery
Aniruddh25 May 17, 2022
ac50398
Add comments
Aniruddh25 May 18, 2022
5db5505
Add more comments. to functions and use DataGatewayException
Aniruddh25 May 18, 2022
727170d
Default primary key name const
Aniruddh25 May 18, 2022
1ac4244
Fix more comments
Aniruddh25 May 18, 2022
8351b15
Fix more review comments
Aniruddh25 May 18, 2022
9c53243
Merge remote-tracking branch 'origin/main' into dev/anmunde/graphql-s…
Aniruddh25 May 18, 2022
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: 1 addition & 1 deletion DataGateway.Config/Action.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public enum Operation
Upsert, Create,

// Sql operations
Insert, Update,
Insert, Update, UpdateGraphQL,

// Additional
UpsertIncremental, UpdateIncremental
Expand Down
11 changes: 6 additions & 5 deletions DataGateway.Config/DataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ namespace Azure.DataGateway.Config
/// will use to connect to the backend database.</param>
public record DataSource(
[property: JsonPropertyName(DataSource.DATABASE_PROPERTY_NAME)]
DatabaseType DatabaseType,
[property: JsonPropertyName(DataSource.RESOLVER_JSON_PROPERTY_NAME)]
string? ResolverConfigFile)
DatabaseType DatabaseType)
{
public const string JSON_PROPERTY_NAME = "data-source";
public const string DATABASE_PROPERTY_NAME = "database-type";
public const string CONNSTRING_PROPERTY_NAME = "connection-string";
public const string RESOLVER_JSON_PROPERTY_NAME = "resolver-config-file";

public string GetDatabaseTypeNotSupportedMessage()
{
Expand All @@ -32,8 +29,12 @@ public string GetDatabaseTypeNotSupportedMessage()
/// <summary>
/// Options for CosmosDb database.
/// </summary>
public record CosmosDbOptions(string Database)
public record CosmosDbOptions(
string Database,
[property: JsonPropertyName(CosmosDbOptions.RESOLVER_JSON_PROPERTY_NAME)]
string ResolverConfigFile)
Comment thread
Aniruddh25 marked this conversation as resolved.
{
public const string RESOLVER_JSON_PROPERTY_NAME = "resolver-config-file";
public const string JSON_PROPERTY_NAME = nameof(DatabaseType.cosmos);
}

Expand Down
99 changes: 93 additions & 6 deletions DataGateway.Config/DatabaseObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,38 @@ public class DatabaseObject

public TableDefinition TableDefinition { get; set; } = null!;

public DatabaseObject(string schemaName, string tableName)
{
SchemaName = schemaName;
Name = tableName;
}

public DatabaseObject() { }

public string FullName
{
get
{
return string.IsNullOrEmpty(SchemaName) ? Name : $"{SchemaName}.{Name}";
}
}

public override bool Equals(object? other)
{
return Equals(other as DatabaseObject);
}

public bool Equals(DatabaseObject? other)
{
return other is not null &&
SchemaName.Equals(other.SchemaName) &&
Name.Equals(other.Name);
}

public override int GetHashCode()
{
return HashCode.Combine(SchemaName, Name);
}
}

public class TableDefinition
Expand All @@ -26,10 +51,34 @@ public class TableDefinition
/// The list of columns that together form the primary key of the table.
/// </summary>
public List<string> PrimaryKey { get; set; } = new();
public Dictionary<string, ColumnDefinition> Columns { get; set; } =

/// <summary>
/// The list of columns in this table.
/// </summary>
public Dictionary<string, ColumnDefinition> Columns { get; private set; } =
new(StringComparer.InvariantCultureIgnoreCase);
public Dictionary<string, ForeignKeyDefinition> ForeignKeys { get; set; } = new();
public Dictionary<string, AuthorizationRule> HttpVerbs { get; set; } = new();

/// <summary>
/// A dictionary mapping all the source entities to their relationship metadata.
/// All these entities share this table definition
/// as their underlying database object
/// </summary>
public Dictionary<string, RelationshipMetadata> SourceEntityRelationshipMap { get; private set; } =
new(StringComparer.InvariantCultureIgnoreCase);

public Dictionary<string, AuthorizationRule> HttpVerbs { get; private set; } = new();
}

/// <summary>
/// Class encapsulating foreign keys corresponding to target entities.
/// </summary>
public class RelationshipMetadata
{
/// <summary>
/// Dictionary of target entity name to ForeignKeyDefinition.
/// </summary>
public Dictionary<string, List<ForeignKeyDefinition>> TargetEntityToFkDefinitionMap { get; private set; }
= new(StringComparer.InvariantCultureIgnoreCase);
}

public class ColumnDefinition
Expand All @@ -46,7 +95,10 @@ public class ColumnDefinition

public class ForeignKeyDefinition
{
public string ReferencedTable { get; set; } = string.Empty;
/// <summary>
/// The referencing and referenced table pair.
/// </summary>
public RelationShipPair Pair { get; set; } = new();

/// <summary>
/// The list of columns referenced in the reference table.
Expand All @@ -70,15 +122,50 @@ public override bool Equals(object? other)
public bool Equals(ForeignKeyDefinition? other)
{
return other != null &&
ReferencedTable.Equals(other.ReferencedTable) &&
Pair.Equals(other.Pair) &&
ReferencedColumns.SequenceEqual(other.ReferencedColumns) &&
ReferencingColumns.SequenceEqual(other.ReferencingColumns);
}

public override int GetHashCode()
{
return HashCode.Combine(
ReferencedTable, ReferencedColumns, ReferencingColumns);
Pair, ReferencedColumns, ReferencingColumns);
}
}

public class RelationShipPair
{
public RelationShipPair() { }

public RelationShipPair(
DatabaseObject referencingDbObject,
DatabaseObject referencedDbObject)
{
ReferencingDbObject = referencingDbObject;
ReferencedDbObject = referencedDbObject;
}

public DatabaseObject ReferencingDbObject { get; set; } = new();

public DatabaseObject ReferencedDbObject { get; set; } = new();

public override bool Equals(object? other)
{
return Equals(other as RelationShipPair);
}

public bool Equals(RelationShipPair? other)
{
return other != null &&
ReferencedDbObject.Equals(other.ReferencedDbObject) &&
ReferencingDbObject.Equals(other.ReferencingDbObject);
}

public override int GetHashCode()
{
return HashCode.Combine(
ReferencedDbObject, ReferencingDbObject);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private static ITypeNode GenerateListType(ITypeNode type, ITypeNode fieldType)

private static NameNode GenerateInputTypeName(string typeName, Entity entity)
{
return new($"Create{FormatNameForObject(typeName, entity)}Input");
return new($"{Operation.Create}{FormatNameForObject(typeName, entity)}Input");
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,34 @@ internal static class DeleteMutationBuilder
{
public static FieldDefinitionNode Build(NameNode name, ObjectTypeDefinitionNode objectTypeDefinitionNode, Entity configEntity)
{
FieldDefinitionNode idField = FindPrimaryKeyField(objectTypeDefinitionNode);
List<FieldDefinitionNode> idFields = FindPrimaryKeyFields(objectTypeDefinitionNode);
string description;
if (idFields.Count > 1)
{
description = "One of the ids of the item being deleted.";
}
else
{
description = "The ID of the item being deleted.";
}

List<InputValueDefinitionNode> inputValues = new();
foreach (FieldDefinitionNode idField in idFields)
{
inputValues.Add(new InputValueDefinitionNode(
location: null,
idField.Name,
new StringValueNode(description),
new NonNullTypeNode(idField.Type.NamedType()),
defaultValue: null,
new List<DirectiveNode>()));
}

return new(
null,
new NameNode($"delete{FormatNameForObject(name, configEntity)}"),
new StringValueNode($"Delete a {name}"),
new List<InputValueDefinitionNode> {
new InputValueDefinitionNode(
null,
idField.Name,
new StringValueNode($"Id of the item to delete"),
new NonNullTypeNode(idField.Type.NamedType()),
null,
new List<DirectiveNode>())
},
inputValues,
new NamedTypeNode(FormatNameForObject(name, configEntity)),
new List<DirectiveNode>()
);
Expand Down
10 changes: 10 additions & 0 deletions DataGateway.Service.GraphQLBuilder/Mutations/MutationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,15 @@ public static DocumentNode Build(DocumentNode root, DatabaseType databaseType, I
definitionNodes.AddRange(inputs.Values);
return new(definitionNodes);
}

public static Operation DetermineMutationOperationTypeBasedOnInputType(string inputTypeName)
{
return inputTypeName switch
{
string s when s.StartsWith(Operation.Create.ToString(), StringComparison.OrdinalIgnoreCase) => Operation.Create,
string s when s.StartsWith(Operation.Update.ToString(), StringComparison.OrdinalIgnoreCase) => Operation.UpdateGraphQL,
_ => Operation.Delete
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private static InputValueDefinitionNode GetComplexInputType(

private static NameNode GenerateInputTypeName(string typeName, Entity entity)
{
return new($"Update{FormatNameForObject(typeName, entity)}Input");
return new($"{Operation.Update}{FormatNameForObject(typeName, entity)}Input");
}

/// <summary>
Expand All @@ -158,29 +158,42 @@ public static FieldDefinitionNode Build(
DatabaseType databaseType)
{
InputObjectTypeDefinitionNode input = GenerateUpdateInputType(inputs, objectTypeDefinitionNode, name, root.Definitions.Where(d => d is HotChocolate.Language.IHasName).Cast<HotChocolate.Language.IHasName>(), entity, databaseType);
List<FieldDefinitionNode> idFields = FindPrimaryKeyFields(objectTypeDefinitionNode);
string description;
if (idFields.Count() > 1)
{
description = "One of the ids of the item being updated.";
}
else
{
description = "The ID of the item being updated.";
}

FieldDefinitionNode idField = FindPrimaryKeyField(objectTypeDefinitionNode);

return new(
location: null,
new NameNode($"update{FormatNameForObject(name, entity)}"),
new StringValueNode($"Updates a {name}"),
new List<InputValueDefinitionNode> {
new InputValueDefinitionNode(
List<InputValueDefinitionNode> inputValues = new();
foreach (FieldDefinitionNode idField in idFields)
{
inputValues.Add(new InputValueDefinitionNode(
location: null,
idField.Name,
new("The ID of the item being updated"),
new StringValueNode(description),
new NonNullTypeNode(idField.Type.NamedType()),
defaultValue: null,
new List<DirectiveNode>()),
new InputValueDefinitionNode(
new List<DirectiveNode>()));
}

inputValues.Add(new InputValueDefinitionNode(
location: null,
new NameNode(INPUT_ARGUMENT_NAME),
new StringValueNode($"Input representing all the fields for updating {name}"),
new NonNullTypeNode(new NamedTypeNode(input.Name)),
defaultValue: null,
new List<DirectiveNode>())
},
new List<DirectiveNode>()));

return new(
location: null,
new NameNode($"update{FormatNameForObject(name, entity)}"),
new StringValueNode($"Updates a {name}"),
inputValues,
new NamedTypeNode(FormatNameForObject(name, entity)),
new List<DirectiveNode>()
);
Expand Down
31 changes: 19 additions & 12 deletions DataGateway.Service.GraphQLBuilder/Queries/QueryBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace Azure.DataGateway.Service.GraphQLBuilder.Queries
public static class QueryBuilder
{
public const string PAGINATION_FIELD_NAME = "items";
public const string PAGINATION_TOKEN_FIELD_NAME = "after";
public const string PAGINATION_TOKEN_FIELD_NAME = "endCursor";
public const string PAGINATION_TOKEN_ARGUMENT_NAME = "after";
public const string HAS_NEXT_PAGE_FIELD_NAME = "hasNextPage";
public const string PAGE_START_ARGUMENT_NAME = "first";
public const string PAGINATION_OBJECT_TYPE_SUFFIX = "Connection";
Expand Down Expand Up @@ -48,20 +49,26 @@ public static DocumentNode Build(DocumentNode root, IDictionary<string, Entity>

private static FieldDefinitionNode GenerateByPKQuery(ObjectTypeDefinitionNode objectTypeDefinitionNode, NameNode name)
{
FieldDefinitionNode primaryKeyField = FindPrimaryKeyField(objectTypeDefinitionNode);
return new(
location: null,
new NameNode($"{FormatNameForField(name)}_by_pk"),
new StringValueNode($"Get a {name} from the database by its ID/primary key"),
new List<InputValueDefinitionNode> {
new InputValueDefinitionNode(
location : null,
IEnumerable<FieldDefinitionNode> primaryKeyFields =
FindPrimaryKeyFields(objectTypeDefinitionNode);
List<InputValueDefinitionNode> inputValues = new();

foreach (FieldDefinitionNode primaryKeyField in primaryKeyFields)
{
inputValues.Add(new InputValueDefinitionNode(
location: null,
primaryKeyField.Name,
description: null,
primaryKeyField.Type,
defaultValue: null,
new List<DirectiveNode>())
},
new List<DirectiveNode>()));
}

return new(
location: null,
new NameNode($"{FormatNameForField(name)}_by_pk"),
new StringValueNode($"Get a {name} from the database by its ID/primary key"),
inputValues,
new NamedTypeNode(name),
new List<DirectiveNode>()
);
Expand Down Expand Up @@ -99,7 +106,7 @@ private static List<InputValueDefinitionNode> QueryArgumentsForField(string filt
return new()
{
new(location: null, new NameNode(PAGE_START_ARGUMENT_NAME), description: new StringValueNode("The number of items to return from the page start point"), new IntType().ToTypeNode(), defaultValue: null, new List<DirectiveNode>()),
new(location: null, new NameNode(PAGINATION_TOKEN_FIELD_NAME), new StringValueNode("A pagination token from a previous query to continue through a paginated list"), new StringType().ToTypeNode(), defaultValue: null, new List<DirectiveNode>()),
new(location: null, new NameNode(PAGINATION_TOKEN_ARGUMENT_NAME), new StringValueNode("A pagination token from a previous query to continue through a paginated list"), new StringType().ToTypeNode(), defaultValue: null, new List<DirectiveNode>()),
new(location: null, new NameNode(FILTER_FIELD_NAME), new StringValueNode("Filter options for query"), new NamedTypeNode(filterInputName), defaultValue: null, new List<DirectiveNode>()),
new(location: null, new NameNode(ODATA_FILTER_FIELD_NAME), new StringValueNode("Filter options for query expressed as OData query language"), new StringType().ToTypeNode(), defaultValue: null, new List<DirectiveNode>())
};
Expand Down
Loading