- 
                Notifications
    
You must be signed in to change notification settings  - Fork 33
 
Simplify GenericInputObjectFieldDefinitions #195
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
Simplify GenericInputObjectFieldDefinitions #195
Conversation
9793f68    to
    30f58e4      
    Compare
  
    | 
           Thanks for the PR. The test failure is due to our coverage ratchet. Because you improve the test coverage (yay!), you need to update the   | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Need to bump the coverage ratchet as mentioned in my earlier comment.
We simplify `GenericInputObjectFieldDefinitions` by using
tree-recursion, resulting in better error messages. Example
code to reproduce below, where the 'true' error is usage of
lists.
```hs
data family Test :: Nat -> Type
data instance Test 1 = Test
  { testField1 :: Int32
  , testField2 :: Text
  , testField3 :: Text
  , testField4 :: [Int32]
  } deriving (Show, Generic)
instance HasAnnotatedInputType Test
```
Before
```
        • No instance for (GraphQL.Internal.API.GenericInputObjectFieldDefinitions
                             ((S1
                                 ('MetaSel
                                    ('Just "testField1")
                                    'NoSourceUnpackedness
                                    'NoSourceStrictness
                                    'DecidedLazy)
                                 (Rec0 Int32)
                               :*: S1
                                     ('MetaSel
                                        ('Just "testField2")
                                        'NoSourceUnpackedness
                                        'NoSourceStrictness
                                        'DecidedLazy)
                                     (Rec0 Text))
                              :*: (S1
                                     ('MetaSel
                                        ('Just "testField3")
                                        'NoSourceUnpackedness
                                        'NoSourceStrictness
                                        'DecidedLazy)
                                     (Rec0 Text)
                                   :*: S1
                                         ('MetaSel
                                            ('Just "testField4")
                                            'NoSourceUnpackedness
                                            'NoSourceStrictness
                                            'DecidedLazy)
                                         (Rec0 [Int32]))))
            arising from a use of ‘GraphQL.Internal.API.$dmgetAnnotatedInputType’
        • In the expression:
            GraphQL.Internal.API.$dmgetAnnotatedInputType @(Test 1)
          In an equation for ‘QL.getAnnotatedInputType’:
              QL.getAnnotatedInputType
                = GraphQL.Internal.API.$dmgetAnnotatedInputType @(Test 1)
          In the instance declaration for ‘QL.HasAnnotatedInputType (Test 1)’
       |
    72 | instance QL.HasAnnotatedInputType (Test 1)
       |
```
After
```
    • No instance for (QL.HasAnnotatedInputType [Int32])
      arising from a use of ‘GraphQL.Internal.API.$dmgetAnnotatedInputType’
    • In the expression:
        GraphQL.Internal.API.$dmgetAnnotatedInputType @(Test 1)
      In an equation for ‘QL.getAnnotatedInputType’:
          QL.getAnnotatedInputType
            = GraphQL.Internal.API.$dmgetAnnotatedInputType @(Test 1)
      In the instance declaration for ‘QL.HasAnnotatedInputType (Test 1)’
    |
72  | instance QL.HasAnnotatedInputType (Test 1)
    |
```
    30f58e4    to
    5747b88      
    Compare
  
    | 
           Done! Tests are looking good now.  | 
    
| 
           @jml anything else I can do to get the PR merged?  | 
    
| 
           All good. Sorry for the delay.  | 
    
We simplify
GenericInputObjectFieldDefinitionsby usingtree-recursion, resulting in better error messages. Example
code to reproduce below, where the 'true' error is usage of
lists.
Before
After