From 12a9d29c3d06f28935d4f4c5699aae8f11f04bd2 Mon Sep 17 00:00:00 2001 From: Mohd Saqueib Ansari Date: Wed, 30 Aug 2017 07:11:08 +0530 Subject: [PATCH] added required filed types on Type --- app/GraphQL/Type/TweetType.php | 23 ++++++++++++++++++- app/GraphQL/Type/UserType.php | 40 +++++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/app/GraphQL/Type/TweetType.php b/app/GraphQL/Type/TweetType.php index e6b64c1..e73ea4a 100644 --- a/app/GraphQL/Type/TweetType.php +++ b/app/GraphQL/Type/TweetType.php @@ -32,10 +32,31 @@ public function fields() 'likes_count' => [ 'type' => Type::int() ], - // Nested Resource 'user' => [ 'type' => GraphQL::type('User') + ], + 'replies' => [ + 'args' => [ + 'id' => [ + 'type' => Type::int(), + ], + 'first' => [ + 'type' => Type::int(), + ], + ], + 'type' => Type::listOf(GraphQL::type('Reply')), + ], + 'likes' => [ + 'args' => [ + 'id' => [ + 'type' => Type::int(), + ], + 'first' => [ + 'type' => Type::int(), + ], + ], + 'type' => Type::listOf(GraphQL::type('Like')), ] ]; } diff --git a/app/GraphQL/Type/UserType.php b/app/GraphQL/Type/UserType.php index e8bf04d..22b4ae4 100644 --- a/app/GraphQL/Type/UserType.php +++ b/app/GraphQL/Type/UserType.php @@ -49,11 +49,49 @@ public function fields() ], 'is_following' => [ 'type' => Type::boolean() + ], + 'is_followed' => [ + 'type' => Type::boolean() + ], + 'tweets' => [ + 'args' => [ + 'id' => [ + 'type' => Type::int(), + ], + 'first' => [ + 'type' => Type::int(), + ], + ], + 'type' => Type::listOf(GraphQL::type('Tweet')) + ], + 'profile' => [ + 'type' => GraphQL::type('Profile') + ], + 'followers' => [ + 'args' => [ + 'id' => [ + 'type' => Type::int(), + ], + 'first' => [ + 'type' => Type::int(), + ], + ], + 'type' => Type::listOf(GraphQL::type('User')) + ], + 'following' => [ + 'args' => [ + 'id' => [ + 'type' => Type::int(), + ], + 'first' => [ + 'type' => Type::int(), + ], + ], + 'type' => Type::listOf(GraphQL::type('User')) ] ]; } - // If you want to resolve the field yourself, you can declare a method // with the following format resolve[FIELD_NAME]Field() protected function resolveEmailField($root, $args)