@@ -295,9 +295,9 @@ private DocumentNode GenerateSqlGraphQLObjects(RuntimeEntities entities, Diction
295295 Dictionary < string , IEnumerable < string > > rolesAllowedForFields = new ( ) ;
296296 SourceDefinition sourceDefinition = sqlMetadataProvider . GetSourceDefinition ( entityName ) ;
297297 bool isStoredProcedure = entity . Source . Type is EntitySourceType . StoredProcedure ;
298+ EntityActionOperation operation = isStoredProcedure ? EntityActionOperation . Execute : EntityActionOperation . Read ;
298299 foreach ( string column in sourceDefinition . Columns . Keys )
299300 {
300- EntityActionOperation operation = isStoredProcedure ? EntityActionOperation . Execute : EntityActionOperation . Read ;
301301 IEnumerable < string > roles = _authorizationResolver . GetRolesForField ( entityName , field : column , operation : operation ) ;
302302 if ( ! rolesAllowedForFields . TryAdd ( key : column , value : roles ) )
303303 {
@@ -309,7 +309,6 @@ private DocumentNode GenerateSqlGraphQLObjects(RuntimeEntities entities, Diction
309309 }
310310 }
311311
312- // The roles allowed for Fields are the roles allowed to READ the fields, so any role that has a read definition for the field.
313312 // Only add objectTypeDefinition for GraphQL if it has a role definition defined for access.
314313 if ( rolesAllowedForEntity . Any ( ) )
315314 {
@@ -397,23 +396,18 @@ private DocumentNode GenerateSqlGraphQLObjects(RuntimeEntities entities, Diction
397396 GenerateSourceTargetLinkingObjectDefinitions ( objectTypes , linkingObjectTypes ) ;
398397 }
399398
400- // Return a list of all the object types to be exposed in the schema.
401- Dictionary < string , FieldDefinitionNode > fields = new ( ) ;
402-
403- // Add the DBOperationResult type to the schema
404399 NameNode nameNode = new ( value : GraphQLUtils . DB_OPERATION_RESULT_TYPE ) ;
405- FieldDefinitionNode field = GetDbOperationResultField ( ) ;
406-
407- fields . TryAdd ( GraphQLUtils . DB_OPERATION_RESULT_FIELD_NAME , field ) ;
408400
401+ // Add the DBOperationResult type to the schema
409402 objectTypes . Add ( GraphQLUtils . DB_OPERATION_RESULT_TYPE , new ObjectTypeDefinitionNode (
410403 location : null ,
411404 name : nameNode ,
412405 description : null ,
413406 new List < DirectiveNode > ( ) ,
414407 new List < NamedTypeNode > ( ) ,
415- fields . Values . ToImmutableList ( ) ) ) ;
408+ ImmutableList . Create ( GetDbOperationResultField ( ) ) ) ) ;
416409
410+ // Return a list of all the object types to be exposed in the schema.
417411 List < IDefinitionNode > nodes = new ( objectTypes . Values ) ;
418412 nodes . AddRange ( enumTypes . Values ) ;
419413 return new DocumentNode ( nodes ) ;
@@ -748,7 +742,7 @@ private static FieldDefinitionNode GetDbOperationResultField()
748742 DocumentNode cosmosResult = GenerateCosmosGraphQLObjects ( cosmosDataSourceNames , inputObjects ) ;
749743 DocumentNode sqlResult = GenerateSqlGraphQLObjects ( sql , inputObjects ) ;
750744 // Create Root node with definitions from both cosmos and sql.
751- DocumentNode root = new ( cosmosResult . Definitions . Concat ( sqlResult . Definitions ) . ToImmutableList ( ) ) ;
745+ DocumentNode root = cosmosResult . WithDefinitions ( cosmosResult . Definitions . Concat ( sqlResult . Definitions ) . ToImmutableList ( ) ) ;
752746
753747 // Merge the inputobjectType definitions from cosmos and sql onto the root.
754748 return ( root . WithDefinitions ( root . Definitions . Concat ( inputObjects . Values ) . ToImmutableList ( ) ) , inputObjects ) ;
0 commit comments