Skip to content

Conversation

@evanmcneely
Copy link
Contributor

@evanmcneely evanmcneely commented May 23, 2022

Summary

Changes are not 100% ready but I am requesting feedback and input on 1 particular problem I am having.

When working with lists in graphQL, the type complexity of the query is dependent on the number of objects returned in the list. For example, on line 190 in buildTypeWeights.test.ts:

'type Query {
     reviews(episode: Episode!, first: Int): [Review]
}'

the field reviews is a list, with the number of reviews included in the response dependent on the argument passed in for first. If first is 3 than the type complexity of the reviews field in the query is 3, since it returns 3 Review objects in the response. The challenge is how to represent this in the typeWeightsObject (if it should be). I currently have the expected field weight for the Review type set to 1. Maybe this is something the complexity algorithm should deal with since it knows the argument passed in to first?

Type of Change

  • New feature (non-breaking change which adds functionality)

Issues

Evidence

Screen Shot 2022-05-23 at 10 12 54 AM

@evanmcneely evanmcneely changed the title Em/type weights test Extended test suite of 'typeWeightObject' to account for lists, enums, interfaces and unions May 23, 2022
Copy link
Collaborator

@shalarewicz shalarewicz left a comment

Choose a reason for hiding this comment

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

Great work! Left a few comments. We can discuss further if needed.

Copy link
Collaborator

@jondeweydev jondeweydev left a comment

Choose a reason for hiding this comment

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

I wish I could add any insight, if we can find time to quickly talk through the code, perhaps I can add another perspective, but as of reading it now it looks thoughtful. I would recommend adding more comments to the code in the future

@evanmcneely evanmcneely merged commit f2e5764 into dev May 28, 2022
@evanmcneely evanmcneely deleted the em/typeWeightsTest branch May 28, 2022 16:00
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.

Extend the test suite for 'buildTypeWeights' function to account for LISTS, ENUMS, INTERFACES, UNIONS, INPUT TYPES in a schema object

4 participants