Skip to content

Generating name and description fields for queries and mutations as per the naming guidelines#619

Merged
severussundar merged 100 commits into
mainfrom
dev/shyamsundarj/singularizing-entity-names-for-delete-mutations-in-schema
Aug 12, 2022
Merged

Generating name and description fields for queries and mutations as per the naming guidelines#619
severussundar merged 100 commits into
mainfrom
dev/shyamsundarj/singularizing-entity-names-for-delete-mutations-in-schema

Conversation

@severussundar

@severussundar severussundar commented Jul 29, 2022

Copy link
Copy Markdown
Contributor

Naming Guidelines

We assume that the entity name defined by the user will be singular. Users have the option to provide singular and plural names for the entities through the config. When singular and plural names are provided, the queries and mutations will be generated with these specified names. When they are not specified, the entity name will be used for generating the query and mutation fields in the schema. The _by_pk and list queries will be generated with first letter in lowercase as a best practice.

What is the Change?

The following fields were changed to follow the naming guidelines.

  • Name and description for _by_pk query field.

  • Name and description for the query to fetch all items

  • Description for mutations

How was this tested?

  • Unit tests

  • Updating the config files with singular plural definitions and checking the schema

  • Entity Stocks has the following graphQL definition in the config file.

"Stocks": { "source": "stocks", "rest": true, "graphql": { "type": { "singular": "Stock", "plural": "Stocks" } }

  • Queries:

Stocks Query

  • Mutations:

Create Mutation

Update Mutation

Delete Mutation

@aaronpowell

Copy link
Copy Markdown
Contributor

Are we potentially breaking the naming expectations that a person has from their database?

If we have a table named People we're saying that you're going to have to refer to the entity as Person in the schema for singlar operations (mutation deletePerson not mutation deletePeople), which means that we're really overriding their naming design.

Is that a level of opinionation that we're happy to have in the runtime?

Comment thread DataGateway.Service.GraphQLBuilder/Mutations/DeleteMutationBuilder.cs Outdated
Comment thread src/Service.GraphQLBuilder/Mutations/CreateMutationBuilder.cs Outdated
Comment thread src/Service/Configurations/RuntimeConfigValidator.cs Outdated
@severussundar severussundar added bug Something isn't working and removed bug Something isn't working labels Aug 12, 2022
@severussundar severussundar self-assigned this Aug 12, 2022
Comment thread src/Service.Tests/GraphQLBuilder/Helpers/GraphQLTestHelpers.cs
Comment thread src/Service.Tests/GraphQLBuilder/MutationBuilderTests.cs Outdated
Comment thread src/Service/Configurations/RuntimeConfigValidator.cs Outdated
Comment thread src/Service.Tests/GraphQLBuilder/MutationBuilderTests.cs Outdated
Comment thread src/Service.GraphQLBuilder/Queries/QueryBuilder.cs

@seantleonard seantleonard left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for bringing to finish line. A few comments/nits about checks on tests for pluralize being not null.

@Aniruddh25 Aniruddh25 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for pushing through this and validating the various scenarios.

@severussundar
severussundar merged commit f35038e into main Aug 12, 2022
@severussundar
severussundar deleted the dev/shyamsundarj/singularizing-entity-names-for-delete-mutations-in-schema branch August 12, 2022 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GraphQL Schema Gen: Singularize mutation by id

5 participants