Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New graphql schema #662

Merged
merged 32 commits into from
Mar 25, 2021
Merged

New graphql schema #662

merged 32 commits into from
Mar 25, 2021

Conversation

adriangmweb
Copy link
Contributor

@adriangmweb adriangmweb commented Mar 8, 2021

Description

Note: This branch has been extended from #616 as the metadata reflection introduced by the TypeScript transformers is necessary. Unfortunately, this has its limitations as stated in #661.

This branch introduces the GraphQL new schema in the core, allowing filtering by more than one property at the same time and by complex properties as well in queries and subscriptions.

Changes

The GraphQL schema now is way more secure and complete, allows complex and multiple filters instead of just one basic one. Also, the filter API is way more user-friendly.

Checks

  • Project Builds
  • Project passes tests and checks
  • Updated documentation accordingly

Additional information

This PR solves: #600 #602 and also #603

Due to a DynamoDB limitation, the schema has to make use of generic GraphQLJSONType types, which doesn't give much info to the user and doesn't give us full security when updating types. This also doesn't give us the ability yet to query by properties of a complex property that is inside a List. You can see more information about this limitation here #652

Next steps

Refactor the rest of the providers to use the new GraphQL schema, see #601

@boostercloud boostercloud locked and limited conversation to collaborators Mar 8, 2021
@boostercloud boostercloud unlocked this conversation Mar 8, 2021
@boostercloud boostercloud locked and limited conversation to collaborators Mar 9, 2021
@boostercloud boostercloud unlocked this conversation Mar 9, 2021
@adriangmweb adriangmweb marked this pull request as ready for review March 9, 2021 17:50
@boostercloud boostercloud locked and limited conversation to collaborators Mar 9, 2021
@boostercloud boostercloud unlocked this conversation Mar 9, 2021
@boostercloud boostercloud locked and limited conversation to collaborators Mar 9, 2021
@boostercloud boostercloud unlocked this conversation Mar 9, 2021
@boostercloud boostercloud locked and limited conversation to collaborators Mar 9, 2021
@boostercloud boostercloud unlocked this conversation Mar 9, 2021
@boostercloud boostercloud locked and limited conversation to collaborators Mar 10, 2021
@boostercloud boostercloud unlocked this conversation Mar 10, 2021
@adriangmweb adriangmweb requested a review from a team March 10, 2021 08:59
Copy link
Contributor

@juanjoman juanjoman left a comment

Choose a reason for hiding this comment

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

LGTM!! Just left some minor questions ✌️

PS: The docs are amazing <3

@adriangmweb adriangmweb requested a review from a team March 17, 2021 08:44
@boostercloud boostercloud locked and limited conversation to collaborators Mar 19, 2021
@boostercloud boostercloud unlocked this conversation Mar 19, 2021
@boostercloud boostercloud locked and limited conversation to collaborators Mar 19, 2021
@boostercloud boostercloud unlocked this conversation Mar 19, 2021
@boostercloud boostercloud locked and limited conversation to collaborators Mar 19, 2021
@boostercloud boostercloud unlocked this conversation Mar 19, 2021
Copy link
Collaborator

@adrian-lorenzo adrian-lorenzo left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@NickSeagull NickSeagull left a comment

Choose a reason for hiding this comment

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

Thanks a lot! Left some suggestions

docs/README.md Outdated

```graphql
query {
ProductReadModels(filter: { sku: { begingsWith: "jelwery" } }) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ProductReadModels(filter: { sku: { begingsWith: "jelwery" } }) {
ProductReadModels(filter: { sku: { begingsWith: "jewelry" } }) {

docs/README.md Outdated
@@ -1582,6 +1582,142 @@ For more information about queries and how to use them, please check the [GraphQ

Booster GraphQL API also provides support for real-time updates using subscriptions and websocket, to get more information about it go to the [GraphQL API](#subscribing-to-read-models) section.

#### Filtering a read model

Booster GraphQL API provides support for filtering ReadModels on queries, subscriptions and at code level.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Booster GraphQL API provides support for filtering ReadModels on queries, subscriptions and at code level.
The Booster GraphQL API provides support for filtering Read Models on queries, subscriptions and at code level.

docs/README.md Outdated

Booster GraphQL API provides support for filtering ReadModels on queries, subscriptions and at code level.

Using the GraphQL API endpoint you can retrieve the schema of your application so you can see what are the filters for every ReadModel and its properties. You can filter like this:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Using the GraphQL API endpoint you can retrieve the schema of your application so you can see what are the filters for every ReadModel and its properties. You can filter like this:
Using the GraphQL API endpoint you can retrieve the schema of your application so you can see what are the filters for every Read Model and its properties. You can filter like this:

docs/README.md Outdated

Using the GraphQL API endpoint you can retrieve the schema of your application so you can see what are the filters for every ReadModel and its properties. You can filter like this:

Searching for a specific ReadModel by id
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Searching for a specific ReadModel by id
Searching for a specific Read Model by `id`

docs/README.md Outdated

#### Supported filters

The currently supported filters are in the following ones. |
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The currently supported filters are in the following ones. |
The currently supported filters are the following ones:

docs/README.md Outdated
Comment on lines 1705 to 1707
| and | [Filters] | AND - all filters on the list have a match |
| or | [Filters] | OR - At least one filter of the list has a match |
| not | Filter/and/or | The element does not match the filter
Copy link
Member

Choose a reason for hiding this comment

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

This should be formatted probably

@@ -37,7 +39,7 @@ export const template = `{
"scripts": {
"lint:check": "eslint --ext '.js,.ts' **/*.ts",
"lint:fix": "eslint --quiet --fix --ext '.js,.ts' **/*.ts",
"compile": "npx tsc -b tsconfig.json",
"compile": "npx ttypescript -b tsconfig.json",
Copy link
Member

Choose a reason for hiding this comment

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

[rant]

Whyyyyyy 😭😭😭😭 Would've been better to use ts-patch...

Anyways, go on... 🥲

[/rant]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just extended form the existing branch, we'll have plenty of time to change it in the future 🙌🏻

const propertyTypes = Reflect.getMetadata('design:paramtypes', classType)
if (propertyNames.length != propertyTypes.length) {
const meta: ClassMetadata = Reflect.getMetadata('booster:typeinfo', classType)
if (!meta) {
// eslint-disable-next-line prettier/prettier
Copy link
Member

Choose a reason for hiding this comment

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

I believe this line is not needed anymore

Suggested change
// eslint-disable-next-line prettier/prettier

Comment on lines 168 to 170
...{
type: GraphQLJSONObject,
},
Copy link
Member

Choose a reason for hiding this comment

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

Why doing this and not instead:

Suggested change
...{
type: GraphQLJSONObject,
},
type: GraphQLJSONObject,

private generateOperationEnumValuesFor(operationsEnum: AnyClass): GraphQLEnumValueConfigMap {
const enumValuesConfig: GraphQLEnumValueConfigMap = {}
for (const opSymbol in operationsEnum) {
const opName = (operationsEnum as any)[opSymbol]
Copy link
Member

Choose a reason for hiding this comment

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

any police 👮🏻‍♂️

What's the contents of operationsEnum? Maybe we can type it in a better way? Can you explain more please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't create that function, it was added after a rebase, so there isn't much I can tell you here 😅

Copy link
Member

Choose a reason for hiding this comment

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

Ok, keep circulating 👮

@boostercloud boostercloud locked and limited conversation to collaborators Mar 25, 2021
@boostercloud boostercloud unlocked this conversation Mar 25, 2021
@adriangmweb adriangmweb merged commit 23b4537 into main Mar 25, 2021
@adriangmweb adriangmweb deleted the new-graphql-schema branch March 25, 2021 17:17
@adriangmweb adriangmweb restored the new-graphql-schema branch March 29, 2021 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants