GraphQL Entity Naming Changes#609
Merged
Merged
Conversation
…raphQL Object type definition.
Aniruddh25
reviewed
Jul 28, 2022
Aniruddh25
reviewed
Jul 30, 2022
Aniruddh25
reviewed
Jul 30, 2022
Aniruddh25
requested changes
Jul 30, 2022
Aniruddh25
left a comment
Collaborator
There was a problem hiding this comment.
Need to honor singular plural values from config when generating GraphQL type name for a given entity.
…ing according to config.
seantleonard
marked this pull request as ready for review
August 9, 2022 01:43
seantleonard
requested review from
JelteF,
Mathos1432,
aaronburtle,
gledis69,
jarupatj,
mbhaskar and
milismsft
as code owners
August 9, 2022 01:43
Aniruddh25
reviewed
Aug 11, 2022
Aniruddh25
reviewed
Aug 11, 2022
Aniruddh25
reviewed
Aug 11, 2022
Aniruddh25
reviewed
Aug 11, 2022
Aniruddh25
reviewed
Aug 11, 2022
Collaborator
|
nit: edit PR description to reflect |
Aniruddh25
requested changes
Aug 11, 2022
Aniruddh25
reviewed
Aug 11, 2022
…of relevant unit tests.
…also enabled per entity.
…ting some checks per comments and removed bad csproj file addition.
This was referenced Aug 11, 2022
GraphQL Schema Building - Format DB columns names as GQL best practice and map to original name
#692
Open
…lue of model directive argument "name"
Aniruddh25
reviewed
Aug 12, 2022
Aniruddh25
approved these changes
Aug 12, 2022
Aniruddh25
left a comment
Collaborator
There was a problem hiding this comment.
LGTM! Thanks for streamlining our GraphQL naming conventions :)
seantleonard
dismissed
aaronpowell’s stale review
August 12, 2022 01:37
Addressed changes posted, will look into refactoring casting and received later approvals.
seantleonard
added a commit
that referenced
this pull request
Aug 15, 2022
* Fix naming casing issue by removing step to format entity names for GraphQL Object type definition. * add comments. * Add helpers to check GraphQL naming violations. * validation of entity names for GraphQL. * Remove commented code. * Added comments to GraphQLNaming functions * Remove extra name formatting and update comments. * Add format naming back without santizing * Updated comments and logic. * Adding tests and comments. * remove space * Fix entity names to be case-sensitive to match test cases: Magazine -> magazine * GraphQL Naming - deserialize json properly and set graphql schema naming according to config. * Remove commented code and whitespace. * Match test pattern, no catch block, as tests that throw exception will fail anyways. * fix tests and merging of DAB name changes. * Get Model name for graphQL entity in mutation engine for use in authorization resolver where entityName is needed. Move `UnderlyingGraphQLEntityType` helper to GraphQLUtils as it is used commonly across classes now. * Update config files to set GraphQL singular plural, so that tests don't need to be rewritten. Keep PR file count smaller while utilizing functionality provided to us by flexibility of our runtime configuration. * Update tests to use the proper casing of graphQL queries/field names to honor runtime configuration. * Fix mutation tests. * Fix spacing. * Fix spacing and usings. * fix using ordering. * Fixing more tests. and updating configs to reflect graphqlnaming * fix rest tests due to changed entity name "magazine" no longer having uppercase first letter. * Fix the config files to properly set GraphQL singular/plural. * Update model name for Cosmos GQL Schema. * update MySql/PG config. * Fix Cosmos Tests and Logic for building Mutations. * Fix broken tests affected by GraphQL Naming. * REmove unnecessary code. * Remove old / extra code for formatting that is not used due to honoring config graphQL names verbatim. * remove extra spacing not caught by local dotnet format. or was lost in the long log * fix comments * Updated comment. * Updated comments/grammar, usage of regex to not allow spaces and fix of relevant unit tests. * Update model directive to be properly formed. * Conditionally validate graphql settings only if Globally enables and also enabled per entity. * Properly format fields. * fix entity creation in tests due to runtimeconfigvalidation. * Update validation to include all forms of GraphQL entity settings. * Fix cosmos query tests. * Add capability to use graphQL settings if type is a string. Also updating some checks per comments and removed bad csproj file addition. * removed no longer relevant tests. * fix spacing * Update usage of custom directive to properly cast and retrieve the value of model directive argument "name" * simplify code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #601 - which identifies a bug where configuration defined entity names were not honored verbatim in GraphQL requests.
Note: This complements the work done in #619 to further honor singular/plural defined values for GraphQL entities.
Why this Change?
Our GraphQL Schema generation code takes the entity name present in our runtime config file:
and formats it to adhere to the GraphQL Specification naming rules.
and
GraphQL Naming Best Practices
Before this change, the entity name
todowas formatted toTodo(best practice rule formatting). When the formatted name was used in theSqlMetadataProvider method like: _sqlMetadataProvider.GetDatabaseObjectName("Todo"), the lookup fails due to case-sensitivity (not equal totodo).Additionally, other schema fields that utilize the Singular/Plural naming like InputTypeFields and Query/Mutation definitions, honor the runtime config settings.
What is this Change?
Removes the name sanitization mechanism from the
FormatNameForObjecthelper method used to convert an entityName in config to a best practice GraphQL name.This is to adhere to decision made in this comment: #601 (comment)
Bug Fix for Improperly Generated Complex Input Types for Cosmos
A bug was also fixed which improperly created nested input type definitions for Cosmos DB as Cosmos supports nested entity mutations. In the files {Create/Update/Delete}MutationBuilder.cs, the method
GetComplexInputType()improperly generated the InputTypeName using the wrong entity object. Because another method parameter, typeName, has the correct value (reference to nested entity), that value is used.The lines of code that were corrected look like:
NameNode inputTypeName = GenerateInputTypeName(typeName);How was this tested?