1 00:00:00,560 --> 00:00:03,360 thank you very much okay so let's get 2 00:00:02,480 --> 00:00:06,480 started 3 00:00:03,360 --> 00:00:09,599 so i already introduced my talk uh 4 00:00:06,480 --> 00:00:12,960 i'm gonna share my screen here 5 00:00:09,599 --> 00:00:13,679 and yeah so basically there will be 6 00:00:12,960 --> 00:00:15,920 three parts 7 00:00:13,679 --> 00:00:19,279 in this talk the first part is about the 8 00:00:15,920 --> 00:00:21,520 ecosystem the graphql ecosystem in php 9 00:00:19,279 --> 00:00:23,199 it does exist and it is actually quite 10 00:00:21,520 --> 00:00:26,240 large 11 00:00:23,199 --> 00:00:27,359 then how to choose the right library for 12 00:00:26,240 --> 00:00:29,920 your project 13 00:00:27,359 --> 00:00:30,480 if you're doing some php and finally a 14 00:00:29,920 --> 00:00:33,520 demo 15 00:00:30,480 --> 00:00:36,719 of graphqlite 16 00:00:33,520 --> 00:00:40,079 so um about the ecosystem 17 00:00:36,719 --> 00:00:42,000 well i'm sure all of you already know 18 00:00:40,079 --> 00:00:44,239 that when you're doing graphql you need 19 00:00:42,000 --> 00:00:45,600 a graphql client in the browser and a 20 00:00:44,239 --> 00:00:48,320 graphql middleware 21 00:00:45,600 --> 00:00:49,360 on the server side and you have actually 22 00:00:48,320 --> 00:00:52,480 implemented 23 00:00:49,360 --> 00:00:56,399 implementations of graphql middlewares 24 00:00:52,480 --> 00:00:59,039 in all in many languages 25 00:00:56,399 --> 00:01:00,000 of course not js it started there but 26 00:00:59,039 --> 00:01:03,039 also php 27 00:01:00,000 --> 00:01:06,320 java c-sharp or whatever 28 00:01:03,039 --> 00:01:10,080 today we're going to be zooming on php 29 00:01:06,320 --> 00:01:12,560 and if we have a look at the php 30 00:01:10,080 --> 00:01:13,360 graphical middlewares there are actually 31 00:01:12,560 --> 00:01:16,640 two kinds 32 00:01:13,360 --> 00:01:17,600 of uh such middlewares and i will split 33 00:01:16,640 --> 00:01:20,880 them 34 00:01:17,600 --> 00:01:23,920 a bit arbitrarily arbitrarily in two 35 00:01:20,880 --> 00:01:24,799 uh sections ones that i call core 36 00:01:23,920 --> 00:01:26,479 libraries 37 00:01:24,799 --> 00:01:27,920 and another that i call dropper 38 00:01:26,479 --> 00:01:30,880 libraries and 39 00:01:27,920 --> 00:01:31,439 core libraries are actually middlewares 40 00:01:30,880 --> 00:01:34,880 that are 41 00:01:31,439 --> 00:01:39,360 quite low level they are used to parse 42 00:01:34,880 --> 00:01:42,560 the graphical queries to serve 43 00:01:39,360 --> 00:01:45,280 the the the response in json 44 00:01:42,560 --> 00:01:45,920 they are really powerful but they are 45 00:01:45,280 --> 00:01:48,320 kind of 46 00:01:45,920 --> 00:01:50,000 hard to use the the developer the 47 00:01:48,320 --> 00:01:53,119 developer experience 48 00:01:50,000 --> 00:01:55,680 to use such uh library is 49 00:01:53,119 --> 00:01:56,479 kind of poor they're hard to use and so 50 00:01:55,680 --> 00:01:59,759 on top 51 00:01:56,479 --> 00:02:01,840 of those core libraries people build 52 00:01:59,759 --> 00:02:03,920 wrapper libraries which are actually 53 00:02:01,840 --> 00:02:06,399 libraries that use core libraries 54 00:02:03,920 --> 00:02:07,520 and that are more high level more 55 00:02:06,399 --> 00:02:10,160 opinionated 56 00:02:07,520 --> 00:02:12,720 certainly easier to use maybe not that 57 00:02:10,160 --> 00:02:15,200 not as much powerful as the call library 58 00:02:12,720 --> 00:02:16,400 but basically most of the time when you 59 00:02:15,200 --> 00:02:18,480 are doing an application 60 00:02:16,400 --> 00:02:20,640 you will be choosing a verbal diagram 61 00:02:18,480 --> 00:02:23,040 right 62 00:02:20,640 --> 00:02:24,239 in php if we have a look at core 63 00:02:23,040 --> 00:02:26,160 libraries 64 00:02:24,239 --> 00:02:28,160 there are not that many of them there 65 00:02:26,160 --> 00:02:31,360 are actually two right now 66 00:02:28,160 --> 00:02:33,120 there is webinaics which is the de facto 67 00:02:31,360 --> 00:02:35,760 standard in php 68 00:02:33,120 --> 00:02:38,160 almost everybody is using webinx and 69 00:02:35,760 --> 00:02:41,840 then there is a newcomer that is called 70 00:02:38,160 --> 00:02:44,640 ray welty which is developed by 71 00:02:41,840 --> 00:02:45,360 some russian guys it's an active 72 00:02:44,640 --> 00:02:48,640 development 73 00:02:45,360 --> 00:02:50,879 it looks really promising there is no 74 00:02:48,640 --> 00:02:54,560 solid documentation yet 75 00:02:50,879 --> 00:02:56,800 so uh right now if you 76 00:02:54,560 --> 00:02:57,760 need a co-library definitely go to 77 00:02:56,800 --> 00:03:00,959 webonix 78 00:02:57,760 --> 00:03:04,480 but keep an eye and high on 79 00:03:00,959 --> 00:03:06,879 railway there was in the past 80 00:03:04,480 --> 00:03:07,920 more libraries here there was one was 81 00:03:06,879 --> 00:03:10,879 that was called 82 00:03:07,920 --> 00:03:12,400 ushido that has been abandoned in favor 83 00:03:10,879 --> 00:03:14,239 of weaponix so 84 00:03:12,400 --> 00:03:16,480 right now it's pretty much robotics if 85 00:03:14,239 --> 00:03:19,840 you want a core library 86 00:03:16,480 --> 00:03:21,599 and then on top of this core library 87 00:03:19,840 --> 00:03:22,959 there are wrapper libraries and there 88 00:03:21,599 --> 00:03:26,239 are many of them 89 00:03:22,959 --> 00:03:28,879 and today uh 90 00:03:26,239 --> 00:03:29,760 all those libraries are using webonix 91 00:03:28,879 --> 00:03:32,239 under the hood 92 00:03:29,760 --> 00:03:35,200 okay it's a wrapper around webonix to 93 00:03:32,239 --> 00:03:38,480 make it easier to use 94 00:03:35,200 --> 00:03:40,879 so basically we have api platform and 95 00:03:38,480 --> 00:03:41,760 the overblock graphql bundles that are 96 00:03:40,879 --> 00:03:44,319 really 97 00:03:41,760 --> 00:03:46,400 used with the symphony framework if 98 00:03:44,319 --> 00:03:48,400 you're doing laravel you can use 99 00:03:46,400 --> 00:03:50,720 a library called lighthouse i will be 100 00:03:48,400 --> 00:03:52,300 presenting those a bit later 101 00:03:50,720 --> 00:03:54,080 if you're doing um 102 00:03:52,300 --> 00:03:56,959 [Music] 103 00:03:54,080 --> 00:03:59,280 what uh if you're using a cms like 104 00:03:56,959 --> 00:04:02,319 wordpress or drupal 105 00:03:59,280 --> 00:04:05,680 wordpress and drupal have modules 106 00:04:02,319 --> 00:04:08,879 to plug to present a graphql api 107 00:04:05,680 --> 00:04:10,560 so if you want to do a headless cms it's 108 00:04:08,879 --> 00:04:14,159 quite easy using 109 00:04:10,560 --> 00:04:16,880 wordpress or drupal and adding a 110 00:04:14,159 --> 00:04:17,759 a graphql module on them and then there 111 00:04:16,880 --> 00:04:19,440 is graphqlite 112 00:04:17,759 --> 00:04:21,199 which i've been altering for the last 113 00:04:19,440 --> 00:04:23,840 two years and which is 114 00:04:21,199 --> 00:04:24,240 a framework agnostic because you can use 115 00:04:23,840 --> 00:04:29,360 it 116 00:04:24,240 --> 00:04:32,320 whatever the framework you use 117 00:04:29,360 --> 00:04:32,720 let's make a quick look uh a quick zoom 118 00:04:32,320 --> 00:04:35,759 on 119 00:04:32,720 --> 00:04:37,520 webonix okay so webonix it is the core 120 00:04:35,759 --> 00:04:40,880 library here 121 00:04:37,520 --> 00:04:42,240 and how does it look like coding with 122 00:04:40,880 --> 00:04:45,360 webox well 123 00:04:42,240 --> 00:04:48,240 here i've got a graphql type okay 124 00:04:45,360 --> 00:04:48,639 and basically this type is a story it 125 00:04:48,240 --> 00:04:52,639 has 126 00:04:48,639 --> 00:04:55,680 fields with which all have types 127 00:04:52,639 --> 00:04:56,240 building that in webmix the card would 128 00:04:55,680 --> 00:04:59,280 look 129 00:04:56,240 --> 00:05:01,120 like this okay it's kind of verbose 130 00:04:59,280 --> 00:05:02,639 and as i told you the developer 131 00:05:01,120 --> 00:05:04,000 experience is not that great but 132 00:05:02,639 --> 00:05:08,240 basically 133 00:05:04,000 --> 00:05:11,840 i'm creating a type it's its name is 134 00:05:08,240 --> 00:05:14,880 history here and i've got a number of 135 00:05:11,840 --> 00:05:17,120 fields that are declared here with the 136 00:05:14,880 --> 00:05:19,280 type of the field the description 137 00:05:17,120 --> 00:05:20,800 if i've got arguments the arguments are 138 00:05:19,280 --> 00:05:23,120 declared here 139 00:05:20,800 --> 00:05:24,160 and finally i have a resolver that will 140 00:05:23,120 --> 00:05:26,639 be called 141 00:05:24,160 --> 00:05:27,360 when i query this fill the resolver is 142 00:05:26,639 --> 00:05:30,479 called 143 00:05:27,360 --> 00:05:33,919 to fetch the data 144 00:05:30,479 --> 00:05:33,919 this is really verbals right 145 00:05:34,320 --> 00:05:42,479 and also it might look a bit like 146 00:05:39,280 --> 00:05:44,720 some libraries some graphql libraries in 147 00:05:42,479 --> 00:05:46,080 javascript especially if you have been 148 00:05:44,720 --> 00:05:49,680 doing 149 00:05:46,080 --> 00:05:52,800 been using express graphql 150 00:05:49,680 --> 00:05:56,240 webonix started by mimicking a lot what 151 00:05:52,800 --> 00:05:59,440 facebook was doing in its own javascript 152 00:05:56,240 --> 00:06:03,120 library if i want to declare 153 00:05:59,440 --> 00:06:05,919 a query well i'm creating a type query 154 00:06:03,120 --> 00:06:07,600 whose fields are here it's actually 155 00:06:05,919 --> 00:06:08,000 exactly the same thing as defining a 156 00:06:07,600 --> 00:06:10,880 type 157 00:06:08,000 --> 00:06:11,440 because in graphql a query is a field on 158 00:06:10,880 --> 00:06:15,759 the 159 00:06:11,440 --> 00:06:18,000 type whose name is query and finally 160 00:06:15,759 --> 00:06:20,000 if i want to resolve a query i can 161 00:06:18,000 --> 00:06:20,800 compose the exit with query static 162 00:06:20,000 --> 00:06:23,440 method 163 00:06:20,800 --> 00:06:24,560 plus in parameters the schema the schema 164 00:06:23,440 --> 00:06:26,639 is 165 00:06:24,560 --> 00:06:28,080 an object containing all the types that 166 00:06:26,639 --> 00:06:31,039 i have declared 167 00:06:28,080 --> 00:06:32,880 i'm passing in the query string so the 168 00:06:31,039 --> 00:06:34,160 graphical query and it will return an 169 00:06:32,880 --> 00:06:37,840 array that that 170 00:06:34,160 --> 00:06:38,960 i can cast to json and return to the 171 00:06:37,840 --> 00:06:43,039 client 172 00:06:38,960 --> 00:06:45,440 so this is the the experience 173 00:06:43,039 --> 00:06:46,240 you're getting when you're using webinx 174 00:06:45,440 --> 00:06:49,599 directly 175 00:06:46,240 --> 00:06:50,479 right and the problem with this approach 176 00:06:49,599 --> 00:06:53,919 is that it 177 00:06:50,479 --> 00:06:57,759 actually requires a lot of work 178 00:06:53,919 --> 00:07:00,720 to set up a great graphql api 179 00:06:57,759 --> 00:07:01,759 obviously there are games to use graphql 180 00:07:00,720 --> 00:07:05,120 versus rest 181 00:07:01,759 --> 00:07:08,560 its queries are client-driven 182 00:07:05,120 --> 00:07:10,080 it has introspection you can see the 183 00:07:08,560 --> 00:07:12,639 schema from the client 184 00:07:10,080 --> 00:07:13,280 it has three types which is definitely 185 00:07:12,639 --> 00:07:15,840 one of the 186 00:07:13,280 --> 00:07:17,039 really cool features but if it is too 187 00:07:15,840 --> 00:07:20,880 much of pain to 188 00:07:17,039 --> 00:07:24,400 um to put the api in place 189 00:07:20,880 --> 00:07:26,880 uh well uh it maybe won't be worth it 190 00:07:24,400 --> 00:07:28,639 so what we are going to do is we are 191 00:07:26,880 --> 00:07:32,479 going to use a wrapper library 192 00:07:28,639 --> 00:07:36,560 which is easier to work with to 193 00:07:32,479 --> 00:07:39,759 offset the gains versus the costs 194 00:07:36,560 --> 00:07:42,319 and to make it worthwhile to use 195 00:07:39,759 --> 00:07:42,319 graphical 196 00:07:42,639 --> 00:07:46,639 now if we need to choose a proper 197 00:07:45,280 --> 00:07:50,000 library 198 00:07:46,639 --> 00:07:53,599 well there are basically two kinds of 199 00:07:50,000 --> 00:07:56,840 such libraries there are 200 00:07:53,599 --> 00:07:58,080 schema first libraries and code first 201 00:07:56,840 --> 00:08:00,960 libraries 202 00:07:58,080 --> 00:08:02,560 in the schema first dropper library 203 00:08:00,960 --> 00:08:04,879 basically 204 00:08:02,560 --> 00:08:06,080 your task as a developer will be to 205 00:08:04,879 --> 00:08:09,520 write the 206 00:08:06,080 --> 00:08:10,240 graphql schema and then the job of the 207 00:08:09,520 --> 00:08:13,599 library 208 00:08:10,240 --> 00:08:16,800 will be from the schema to build 209 00:08:13,599 --> 00:08:19,759 to to find a way to link the schema 210 00:08:16,800 --> 00:08:22,160 to the ph key code on the other end if 211 00:08:19,759 --> 00:08:25,440 you are using a code first approach 212 00:08:22,160 --> 00:08:28,240 you will be designing objects and then 213 00:08:25,440 --> 00:08:29,840 the job of the library will be to 214 00:08:28,240 --> 00:08:31,840 generate the schema 215 00:08:29,840 --> 00:08:34,080 from the classes and the objects you've 216 00:08:31,840 --> 00:08:37,279 been 217 00:08:34,080 --> 00:08:40,320 designing so uh 218 00:08:37,279 --> 00:08:41,120 and basically when you are using a 219 00:08:40,320 --> 00:08:45,519 language 220 00:08:41,120 --> 00:08:48,480 that is loosely typed you tend to have 221 00:08:45,519 --> 00:08:50,399 libraries that are schema first if you 222 00:08:48,480 --> 00:08:52,240 are doing javascript you will find a lot 223 00:08:50,399 --> 00:08:54,720 of schemas libraries 224 00:08:52,240 --> 00:08:56,320 on the other end if you are using a 225 00:08:54,720 --> 00:08:58,720 strictly typed language 226 00:08:56,320 --> 00:09:00,800 like java you will find a lot of code 227 00:08:58,720 --> 00:09:03,839 first libraries 228 00:09:00,800 --> 00:09:04,080 php sits a bit in the middle because it 229 00:09:03,839 --> 00:09:06,320 is 230 00:09:04,080 --> 00:09:07,600 optionally tight you can have types but 231 00:09:06,320 --> 00:09:09,040 you're not forced to 232 00:09:07,600 --> 00:09:10,959 and so you have the two kinds of 233 00:09:09,040 --> 00:09:14,160 libraries out there and 234 00:09:10,959 --> 00:09:16,880 uh basically uh in the schema first 235 00:09:14,160 --> 00:09:18,160 part you have uh overblog lighthouse 236 00:09:16,880 --> 00:09:21,519 reality sciler 237 00:09:18,160 --> 00:09:22,320 and the code first category api platform 238 00:09:21,519 --> 00:09:26,160 graphical light 239 00:09:22,320 --> 00:09:26,160 and get bob 240 00:09:26,880 --> 00:09:30,800 let's make a quick zoom on lighthouse 241 00:09:29,519 --> 00:09:33,680 okay so lighthouse 242 00:09:30,800 --> 00:09:36,320 is a schema first library let's see how 243 00:09:33,680 --> 00:09:41,040 it works 244 00:09:36,320 --> 00:09:43,440 lighthouse is built on top of laravel 245 00:09:41,040 --> 00:09:44,640 when you are using lighthouse what we 246 00:09:43,440 --> 00:09:47,839 you are going to do 247 00:09:44,640 --> 00:09:50,880 is you are going to design this 248 00:09:47,839 --> 00:09:54,399 graphql schema 249 00:09:50,880 --> 00:09:57,680 and basically you are going to annotate 250 00:09:54,399 --> 00:09:58,800 this schema with directives okay this is 251 00:09:57,680 --> 00:10:02,480 a directive 252 00:09:58,800 --> 00:10:05,360 this is another directive and 253 00:10:02,480 --> 00:10:06,560 these directives will be used uh by 254 00:10:05,360 --> 00:10:10,079 lighthouse 255 00:10:06,560 --> 00:10:12,399 to bind this schema to the database 256 00:10:10,079 --> 00:10:15,120 model directly 257 00:10:12,399 --> 00:10:16,560 uh basically under the hood lighthouse 258 00:10:15,120 --> 00:10:19,519 is using yellow points 259 00:10:16,560 --> 00:10:21,440 and yellow point is the orm of laravel 260 00:10:19,519 --> 00:10:24,480 so basically if i'm using the 261 00:10:21,440 --> 00:10:28,640 old directive 262 00:10:24,480 --> 00:10:32,240 automatically lighthouse will put 263 00:10:28,640 --> 00:10:32,800 the current user in the mcquery you can 264 00:10:32,240 --> 00:10:34,800 do 265 00:10:32,800 --> 00:10:36,640 quite powerful stuff with only 266 00:10:34,800 --> 00:10:38,160 directives for instance the create 267 00:10:36,640 --> 00:10:41,040 directive here 268 00:10:38,160 --> 00:10:42,480 will create directly an object in 269 00:10:41,040 --> 00:10:44,959 database 270 00:10:42,480 --> 00:10:46,880 when you when you call critpost and it 271 00:10:44,959 --> 00:10:49,519 will put a post directly into the 272 00:10:46,880 --> 00:10:52,959 database and you can do validation 273 00:10:49,519 --> 00:10:52,959 right here on each field 274 00:10:53,440 --> 00:11:01,120 okay so it's very efficient 275 00:10:57,839 --> 00:11:04,640 i mean you can build a complete 276 00:11:01,120 --> 00:11:06,640 graphql api in very few lines of code 277 00:11:04,640 --> 00:11:10,240 with this approach 278 00:11:06,640 --> 00:11:13,600 also it is very very tied to laravel 279 00:11:10,240 --> 00:11:14,000 and to eloquent which is the oram so if 280 00:11:13,600 --> 00:11:17,440 you want 281 00:11:14,000 --> 00:11:18,880 to do advanced things and if you don't 282 00:11:17,440 --> 00:11:21,440 want to 283 00:11:18,880 --> 00:11:22,399 to be too much tied to your database you 284 00:11:21,440 --> 00:11:25,200 will have to write 285 00:11:22,399 --> 00:11:26,399 a custom directive which is a bit of a 286 00:11:25,200 --> 00:11:28,480 pain 287 00:11:26,399 --> 00:11:29,839 but if you have a simple use case and 288 00:11:28,480 --> 00:11:31,920 you only want to 289 00:11:29,839 --> 00:11:33,920 back to to do quick by binding to a 290 00:11:31,920 --> 00:11:36,399 database it is a great tool 291 00:11:33,920 --> 00:11:38,640 okay one thing that is also interesting 292 00:11:36,399 --> 00:11:43,519 it has support for subscriptions 293 00:11:38,640 --> 00:11:46,880 which is uh so you can do real-time 294 00:11:43,519 --> 00:11:48,800 graph you graphql can 295 00:11:46,880 --> 00:11:51,839 can answer in real time which is not 296 00:11:48,800 --> 00:11:54,880 that common in php 297 00:11:51,839 --> 00:11:58,160 so that is lighthouse let's now make 298 00:11:54,880 --> 00:12:01,440 a zoom on api platform so api platform 299 00:11:58,160 --> 00:12:03,920 okay it is a code first library 300 00:12:01,440 --> 00:12:05,040 in api platform the philosophy is the 301 00:12:03,920 --> 00:12:08,480 opposite 302 00:12:05,040 --> 00:12:11,760 you start by writing a php class 303 00:12:08,480 --> 00:12:15,279 and then you're going to put annotations 304 00:12:11,760 --> 00:12:16,079 on the class an api platform will read 305 00:12:15,279 --> 00:12:18,880 the annotation 306 00:12:16,079 --> 00:12:19,920 and generate the graphical schema for 307 00:12:18,880 --> 00:12:23,360 you 308 00:12:19,920 --> 00:12:25,760 okay um api platform was 309 00:12:23,360 --> 00:12:26,800 first built with the rest philosophy in 310 00:12:25,760 --> 00:12:29,360 mind 311 00:12:26,800 --> 00:12:31,279 and uh what is kind of fun with the api 312 00:12:29,360 --> 00:12:34,079 platform is that you can expose 313 00:12:31,279 --> 00:12:35,600 quite easily both a rest api and a 314 00:12:34,079 --> 00:12:38,160 graphql api 315 00:12:35,600 --> 00:12:41,040 very few lines of code so you get both 316 00:12:38,160 --> 00:12:41,040 kind of api 317 00:12:41,440 --> 00:12:48,240 support using the same code 318 00:12:44,639 --> 00:12:52,240 which is cool however 319 00:12:48,240 --> 00:12:54,079 if you want to have a good control on 320 00:12:52,240 --> 00:12:56,079 you the graphical schema that is 321 00:12:54,079 --> 00:12:59,200 generated api platform 322 00:12:56,079 --> 00:13:01,839 may not be the best uh the best 323 00:12:59,200 --> 00:13:02,560 tool out there because the underlying 324 00:13:01,839 --> 00:13:05,360 philosophy 325 00:13:02,560 --> 00:13:07,279 is very much uh rest so you have credit 326 00:13:05,360 --> 00:13:08,639 you have you can create read update and 327 00:13:07,279 --> 00:13:12,560 delete the report 328 00:13:08,639 --> 00:13:16,240 if you want to do some some other things 329 00:13:12,560 --> 00:13:17,760 uh well it will be a bit harder to 330 00:13:16,240 --> 00:13:21,440 customize 331 00:13:17,760 --> 00:13:24,399 it has support for subscriptions too so 332 00:13:21,440 --> 00:13:24,639 yeah so that was the zoom on lighthouse 333 00:13:24,399 --> 00:13:26,720 and 334 00:13:24,639 --> 00:13:28,240 api platform there are many also 335 00:13:26,720 --> 00:13:31,760 libraries out there 336 00:13:28,240 --> 00:13:34,079 and i've been preparing a few schemas 337 00:13:31,760 --> 00:13:34,880 to help you decide what library you can 338 00:13:34,079 --> 00:13:37,360 use 339 00:13:34,880 --> 00:13:40,160 by answering a few questions so let's 340 00:13:37,360 --> 00:13:40,160 jump into that 341 00:13:40,560 --> 00:13:44,000 so basically if you want to pick a 342 00:13:42,800 --> 00:13:46,399 graphical library 343 00:13:44,000 --> 00:13:48,560 i think the first que and if you are 344 00:13:46,399 --> 00:13:51,519 doing php 345 00:13:48,560 --> 00:13:52,399 the first question you should ask is are 346 00:13:51,519 --> 00:13:55,680 you developing 347 00:13:52,399 --> 00:13:59,040 an application or a tool okay 348 00:13:55,680 --> 00:14:02,560 so basically um 349 00:13:59,040 --> 00:14:05,760 if you are 350 00:14:02,560 --> 00:14:06,399 doing uh if you are developing a tool if 351 00:14:05,760 --> 00:14:09,600 your model 352 00:14:06,399 --> 00:14:14,320 is dynamic for instance if uh 353 00:14:09,600 --> 00:14:16,720 you're sorry 354 00:14:14,320 --> 00:14:17,519 if you are developing a cms and the end 355 00:14:16,720 --> 00:14:20,000 user 356 00:14:17,519 --> 00:14:20,959 can create a new content type you can 357 00:14:20,000 --> 00:14:23,199 create new type 358 00:14:20,959 --> 00:14:24,720 add new fields stuff like that then you 359 00:14:23,199 --> 00:14:26,959 want to go for webinars 360 00:14:24,720 --> 00:14:28,000 okay you want to go low level and build 361 00:14:26,959 --> 00:14:29,920 your own tool 362 00:14:28,000 --> 00:14:31,279 on it if you are developing an 363 00:14:29,920 --> 00:14:31,760 application and you have a set of 364 00:14:31,279 --> 00:14:35,120 classes 365 00:14:31,760 --> 00:14:38,160 already well defined then you want to go 366 00:14:35,120 --> 00:14:38,720 for a wrapper library then there is a 367 00:14:38,160 --> 00:14:41,760 question 368 00:14:38,720 --> 00:14:42,399 do you need subscriptions if you want to 369 00:14:41,760 --> 00:14:45,519 do things 370 00:14:42,399 --> 00:14:47,680 in real time then you have to pick 371 00:14:45,519 --> 00:14:48,959 a library that supports subscriptions 372 00:14:47,680 --> 00:14:51,360 there are not many out there 373 00:14:48,959 --> 00:14:52,399 it's lighthouse api platform silo of all 374 00:14:51,360 --> 00:14:55,519 webinars 375 00:14:52,399 --> 00:14:58,160 otherwise you can choose any library 376 00:14:55,519 --> 00:14:59,040 then there is another question which is 377 00:14:58,160 --> 00:15:02,880 do you want 378 00:14:59,040 --> 00:15:06,079 do you want to do do you want to use 379 00:15:02,880 --> 00:15:09,279 relay on your front end if you are 380 00:15:06,079 --> 00:15:11,600 using relay a relay imposes 381 00:15:09,279 --> 00:15:13,760 a number of constraints of the on the 382 00:15:11,600 --> 00:15:16,399 schemas that are generated 383 00:15:13,760 --> 00:15:17,199 and not all the libraries out there have 384 00:15:16,399 --> 00:15:20,720 support for 385 00:15:17,199 --> 00:15:23,279 this kind of schema so if you want to do 386 00:15:20,720 --> 00:15:24,720 to use relay you should definitely aim 387 00:15:23,279 --> 00:15:28,639 for those libraries 388 00:15:24,720 --> 00:15:31,040 maybe lighthouse and graphical bundles 389 00:15:28,639 --> 00:15:32,000 finally depending on the framework you 390 00:15:31,040 --> 00:15:35,440 are using 391 00:15:32,000 --> 00:15:38,839 you will also have to to put to pick 392 00:15:35,440 --> 00:15:42,320 one of those 393 00:15:38,839 --> 00:15:45,279 libraries some libraries 394 00:15:42,320 --> 00:15:46,880 are framework agnostics like webinarics 395 00:15:45,279 --> 00:15:50,720 and graphic lite and you can use them 396 00:15:46,880 --> 00:15:54,480 everywhere alright so 397 00:15:50,720 --> 00:15:56,079 finally the last question do you prefer 398 00:15:54,480 --> 00:15:59,360 a schema first or 399 00:15:56,079 --> 00:16:02,480 a code first approach if you want 400 00:15:59,360 --> 00:16:04,800 to go schema first pick one here 401 00:16:02,480 --> 00:16:05,759 if you want to go code first pick one 402 00:16:04,800 --> 00:16:09,040 here 403 00:16:05,759 --> 00:16:11,600 and when you unsword all those questions 404 00:16:09,040 --> 00:16:14,160 if you are lucky well you still have a 405 00:16:11,600 --> 00:16:16,000 choice between one or two libraries 406 00:16:14,160 --> 00:16:17,759 if you are unlucky there are no 407 00:16:16,000 --> 00:16:20,240 libraries uh 408 00:16:17,759 --> 00:16:22,240 answering you need for instance if you 409 00:16:20,240 --> 00:16:26,639 want uh to do 410 00:16:22,240 --> 00:16:29,759 to use a code first approach in laravel 411 00:16:26,639 --> 00:16:33,279 and using subscriptions well 412 00:16:29,759 --> 00:16:36,560 you can't basically 413 00:16:33,279 --> 00:16:39,440 and but yes this 414 00:16:36,560 --> 00:16:41,120 approach should help you choose uh one 415 00:16:39,440 --> 00:16:44,240 of those libraries 416 00:16:41,120 --> 00:16:47,839 okay and uh i try to be 417 00:16:44,240 --> 00:16:52,079 not too much biased but yes of course i 418 00:16:47,839 --> 00:16:54,800 i altered a graphic light and so well 419 00:16:52,079 --> 00:16:55,519 now we will enter the third phase of 420 00:16:54,800 --> 00:16:58,320 this talk 421 00:16:55,519 --> 00:16:59,759 and i will be doing a quick demo about 422 00:16:58,320 --> 00:17:03,040 graphic light 423 00:16:59,759 --> 00:17:04,799 before doing the demo i will try to 424 00:17:03,040 --> 00:17:08,079 explain you the philosophy 425 00:17:04,799 --> 00:17:11,839 that drove a graphical light basically 426 00:17:08,079 --> 00:17:15,760 my id was uh well let's imagine 427 00:17:11,839 --> 00:17:18,959 you want to do a simple echo query 428 00:17:15,760 --> 00:17:22,079 in php okay 429 00:17:18,959 --> 00:17:26,240 if you want to do such a query 430 00:17:22,079 --> 00:17:29,679 in graphql it will look like this i'm 431 00:17:26,240 --> 00:17:33,520 creating a query type and basically 432 00:17:29,679 --> 00:17:37,919 yes there is a echo it takes a message 433 00:17:33,520 --> 00:17:41,120 it will return um well i 434 00:17:37,919 --> 00:17:44,880 i'm doing an echo to build that 435 00:17:41,120 --> 00:17:47,520 using webonix i would need to put cisco 436 00:17:44,880 --> 00:17:48,480 i already presented it i need to put an 437 00:17:47,520 --> 00:17:50,480 echo field 438 00:17:48,480 --> 00:17:51,919 which returns a string that takes into 439 00:17:50,480 --> 00:17:54,240 argument a string 440 00:17:51,919 --> 00:17:57,200 and and that results by reading the 441 00:17:54,240 --> 00:18:00,240 arguments and returning them 442 00:17:57,200 --> 00:18:01,600 but if i want to write the same echo in 443 00:18:00,240 --> 00:18:06,400 pure php 444 00:18:01,600 --> 00:18:09,840 basically it only takes four lines 445 00:18:06,400 --> 00:18:13,520 basically the function name could map 446 00:18:09,840 --> 00:18:16,640 the query name in graphql the parameters 447 00:18:13,520 --> 00:18:19,200 here could 448 00:18:16,640 --> 00:18:20,880 map graphical arguments and the return 449 00:18:19,200 --> 00:18:22,640 type is already defined 450 00:18:20,880 --> 00:18:24,799 and then the body of the function is 451 00:18:22,640 --> 00:18:28,400 actually my resolver 452 00:18:24,799 --> 00:18:31,200 so what would be really cool 453 00:18:28,400 --> 00:18:32,000 would be what if i was able to simply 454 00:18:31,200 --> 00:18:35,200 put 455 00:18:32,000 --> 00:18:39,120 a query annotation here 456 00:18:35,200 --> 00:18:42,880 and well this query annotation 457 00:18:39,120 --> 00:18:46,000 uh would automatically 458 00:18:42,880 --> 00:18:46,480 tell my library graphically like in my 459 00:18:46,000 --> 00:18:50,000 case 460 00:18:46,480 --> 00:18:52,160 that this function should be actually 461 00:18:50,000 --> 00:18:53,360 a graphical query expose it in graphql 462 00:18:52,160 --> 00:18:56,320 that's it 463 00:18:53,360 --> 00:18:58,720 and so that's the philosophy behind 464 00:18:56,320 --> 00:19:02,240 graphqlite using annotations 465 00:18:58,720 --> 00:19:06,160 and using the fact that php 466 00:19:02,240 --> 00:19:09,440 is already typed and 467 00:19:06,160 --> 00:19:10,160 basically taking php types and mapping 468 00:19:09,440 --> 00:19:13,200 them 469 00:19:10,160 --> 00:19:15,120 automatically to graphical types so 470 00:19:13,200 --> 00:19:17,440 this is graphic light graphicalite is a 471 00:19:15,120 --> 00:19:20,960 mapper between php types 472 00:19:17,440 --> 00:19:23,679 and graphql types and 473 00:19:20,960 --> 00:19:25,679 what is kind of fun is that it actually 474 00:19:23,679 --> 00:19:29,120 plays quite nice with doctrine 475 00:19:25,679 --> 00:19:32,240 okay doctrine is the orm 476 00:19:29,120 --> 00:19:34,480 used by a symphony 477 00:19:32,240 --> 00:19:37,120 and basically in doctrine you put 478 00:19:34,480 --> 00:19:40,080 annotations in your php objects 479 00:19:37,120 --> 00:19:41,280 and doctrine is doing a mapping between 480 00:19:40,080 --> 00:19:44,000 php objects 481 00:19:41,280 --> 00:19:44,720 and database tables and from the php 482 00:19:44,000 --> 00:19:47,520 objects 483 00:19:44,720 --> 00:19:49,200 it can generate the database model and 484 00:19:47,520 --> 00:19:49,600 with graphilite we are doing the same 485 00:19:49,200 --> 00:19:52,720 thing 486 00:19:49,600 --> 00:19:56,559 we are starting from the php object and 487 00:19:52,720 --> 00:19:56,559 we are generating a graphql schema 488 00:19:57,280 --> 00:20:03,760 yeah so let's go for the live coding 489 00:20:01,840 --> 00:20:05,679 quick note i already told it is 490 00:20:03,760 --> 00:20:08,960 framework agnostic 491 00:20:05,679 --> 00:20:12,240 you can use it starting from php 7.2 492 00:20:08,960 --> 00:20:12,240 and it's based on webonix 493 00:20:13,440 --> 00:20:20,960 now for the hard part for me 494 00:20:17,039 --> 00:20:23,679 the demo yeah so we are going 495 00:20:20,960 --> 00:20:26,559 to uh make a quick demo with a 496 00:20:23,679 --> 00:20:29,760 marketplace and basically my marketplace 497 00:20:26,559 --> 00:20:33,200 has companies and in each company 498 00:20:29,760 --> 00:20:36,159 can have several products and we will be 499 00:20:33,200 --> 00:20:37,520 focusing on this relationship between 500 00:20:36,159 --> 00:20:40,720 companies and products 501 00:20:37,520 --> 00:20:44,000 in the last uh in the next five minutes 502 00:20:40,720 --> 00:20:48,480 right so 503 00:20:44,000 --> 00:20:52,559 let's jump to the code here 504 00:20:48,480 --> 00:20:55,760 i already did set up a 505 00:20:52,559 --> 00:20:58,080 graphql a graphical light in 506 00:20:55,760 --> 00:20:59,360 a symphony project the database is 507 00:20:58,080 --> 00:21:03,520 already loaded 508 00:20:59,360 --> 00:21:06,640 and i wrote a company controller okay so 509 00:21:03,520 --> 00:21:10,720 it's actually a controller like like 510 00:21:06,640 --> 00:21:13,600 like you can find some in nbc frameworks 511 00:21:10,720 --> 00:21:14,240 except it is in the graphql controller 512 00:21:13,600 --> 00:21:16,640 namespace 513 00:21:14,240 --> 00:21:18,000 okay and if you want to put queries or 514 00:21:16,640 --> 00:21:19,840 mutations 515 00:21:18,000 --> 00:21:21,440 somewhere in your code you will put them 516 00:21:19,840 --> 00:21:23,760 in a controller 517 00:21:21,440 --> 00:21:24,799 so my controller is fed with a company 518 00:21:23,760 --> 00:21:27,440 repository 519 00:21:24,799 --> 00:21:28,960 the company repository is the object 520 00:21:27,440 --> 00:21:33,200 that will access the database 521 00:21:28,960 --> 00:21:35,120 okay and i have this 522 00:21:33,200 --> 00:21:36,559 method which is called get companies 523 00:21:35,120 --> 00:21:39,039 that takes 524 00:21:36,559 --> 00:21:40,880 a search string and that will query the 525 00:21:39,039 --> 00:21:42,080 database for the string and return the 526 00:21:40,880 --> 00:21:44,559 results 527 00:21:42,080 --> 00:21:45,520 what i'm going to do is i'm going to put 528 00:21:44,559 --> 00:21:50,080 an annotation 529 00:21:45,520 --> 00:21:53,120 here and 530 00:21:50,080 --> 00:21:55,440 i'm going to put a query annotation to 531 00:21:53,120 --> 00:21:57,980 tell graphic life okay 532 00:21:55,440 --> 00:22:00,640 take this company's 533 00:21:57,980 --> 00:22:03,600 [Music] 534 00:22:00,640 --> 00:22:05,760 function and expose it in the graphql 535 00:22:03,600 --> 00:22:08,720 schema 536 00:22:05,760 --> 00:22:10,400 if i go in firefox here i've got a 537 00:22:08,720 --> 00:22:12,960 graphical 538 00:22:10,400 --> 00:22:13,679 test client setup so i'm going to 539 00:22:12,960 --> 00:22:17,600 refresh 540 00:22:13,679 --> 00:22:20,799 the page and oops 541 00:22:17,600 --> 00:22:24,400 okay i'm getting an error let's make 542 00:22:20,799 --> 00:22:28,480 a quick zoom on this error and basically 543 00:22:24,400 --> 00:22:32,080 what graphicality is telling me is that 544 00:22:28,480 --> 00:22:35,760 in the get companies method a type hint 545 00:22:32,080 --> 00:22:39,280 is missing okay you remember 546 00:22:35,760 --> 00:22:41,600 that php is optionally typed but graphql 547 00:22:39,280 --> 00:22:44,240 must have types so when i'm using 548 00:22:41,600 --> 00:22:47,600 graphqlite i must put type 549 00:22:44,240 --> 00:22:50,960 into all my functions uh 550 00:22:47,600 --> 00:22:53,679 all my queries here i did not define 551 00:22:50,960 --> 00:22:54,000 any return type so i need to define one 552 00:22:53,679 --> 00:22:57,520 so 553 00:22:54,000 --> 00:23:00,000 i'm going to say company get companies 554 00:22:57,520 --> 00:23:01,440 is returning an array of companies now i 555 00:23:00,000 --> 00:23:04,320 have a problem 556 00:23:01,440 --> 00:23:06,720 it's that php does not have the notion 557 00:23:04,320 --> 00:23:08,400 of generics so i cannot say something 558 00:23:06,720 --> 00:23:11,679 like okay it's an array of company 559 00:23:08,400 --> 00:23:12,559 this is not valid php right so what i'm 560 00:23:11,679 --> 00:23:16,320 gonna do 561 00:23:12,559 --> 00:23:19,440 is i'm going to put an uh 562 00:23:16,320 --> 00:23:22,559 a code a command in the php doc and 563 00:23:19,440 --> 00:23:23,280 in the php dock i can put anything and 564 00:23:22,559 --> 00:23:27,360 especially 565 00:23:23,280 --> 00:23:29,360 i will give a type hint to uh 566 00:23:27,360 --> 00:23:31,120 to graph the light and tell him that 567 00:23:29,360 --> 00:23:35,760 this array is actually 568 00:23:31,120 --> 00:23:39,520 an array of companies so let's go back 569 00:23:35,760 --> 00:23:43,120 to firefox refresh the page 570 00:23:39,520 --> 00:23:46,880 and oh i'm getting another error 571 00:23:43,120 --> 00:23:49,360 okay let's zoom on this lever 572 00:23:46,880 --> 00:23:50,480 it's error driven development i'm a big 573 00:23:49,360 --> 00:23:54,960 fan of ever 574 00:23:50,480 --> 00:23:58,720 driven development it works really well 575 00:23:54,960 --> 00:24:01,120 no i and i actually tried to 576 00:23:58,720 --> 00:24:03,200 make sure that all the error messages 577 00:24:01,120 --> 00:24:06,480 are quite clear 578 00:24:03,200 --> 00:24:09,760 it's really important and well 579 00:24:06,480 --> 00:24:12,480 in your own code try uh to pay attention 580 00:24:09,760 --> 00:24:13,760 on the other messages you are generating 581 00:24:12,480 --> 00:24:17,360 you are doing 582 00:24:13,760 --> 00:24:19,840 your future self favor uh yeah 583 00:24:17,360 --> 00:24:21,360 so basically it's telling me that in get 584 00:24:19,840 --> 00:24:24,480 companies 585 00:24:21,360 --> 00:24:26,400 it cannot map the class company to a 586 00:24:24,480 --> 00:24:28,320 known required type 587 00:24:26,400 --> 00:24:30,559 what graduality is actually tell me 588 00:24:28,320 --> 00:24:34,720 telling me is that i did not tell 589 00:24:30,559 --> 00:24:38,080 him explicitly that company 590 00:24:34,720 --> 00:24:40,559 is a graphical type and so to do that 591 00:24:38,080 --> 00:24:42,720 i simply add an annotation which is the 592 00:24:40,559 --> 00:24:46,000 type annotation 593 00:24:42,720 --> 00:24:48,080 and the type annotation is 594 00:24:46,000 --> 00:24:49,679 telling graphical life okay map this 595 00:24:48,080 --> 00:24:52,799 class to a tie 596 00:24:49,679 --> 00:24:53,679 of course a type must have some face so 597 00:24:52,799 --> 00:24:58,000 i'm going to 598 00:24:53,679 --> 00:25:01,279 put annotations in the in the gators 599 00:24:58,000 --> 00:25:04,320 here and i'm going to say okay expose 600 00:25:01,279 --> 00:25:07,520 id as a fill and name 601 00:25:04,320 --> 00:25:10,320 as a field and maybe website 602 00:25:07,520 --> 00:25:10,880 as a field too also notice that i'm 603 00:25:10,320 --> 00:25:14,080 putting 604 00:25:10,880 --> 00:25:16,480 the field annotation on getters i'm not 605 00:25:14,080 --> 00:25:19,440 putting the annotation 606 00:25:16,480 --> 00:25:23,520 on the properties the properties are are 607 00:25:19,440 --> 00:25:23,520 private so i cannot access them directly 608 00:25:23,919 --> 00:25:27,360 doctrine has annotation on properties 609 00:25:26,880 --> 00:25:29,679 because 610 00:25:27,360 --> 00:25:30,480 it is doing some black magic and 611 00:25:29,679 --> 00:25:33,120 actually 612 00:25:30,480 --> 00:25:34,960 accessing directly private properties 613 00:25:33,120 --> 00:25:38,159 i'm not doing that in graphic light 614 00:25:34,960 --> 00:25:39,919 okay so yes i must put the fill 615 00:25:38,159 --> 00:25:43,520 annotation on the getters 616 00:25:39,919 --> 00:25:46,640 so let's go back to 617 00:25:43,520 --> 00:25:50,159 graphical i'm refreshing the page 618 00:25:46,640 --> 00:25:53,440 i don't have any error so it looks good 619 00:25:50,159 --> 00:25:56,799 and if i'm looking at writing a query 620 00:25:53,440 --> 00:26:00,480 i can my company pool will just appear 621 00:25:56,799 --> 00:26:02,640 and yeah i can do a search on any 622 00:26:00,480 --> 00:26:05,200 companies containing the a 623 00:26:02,640 --> 00:26:06,320 and i'm going to display the id and the 624 00:26:05,200 --> 00:26:10,000 name 625 00:26:06,320 --> 00:26:10,799 place the request and it is working and 626 00:26:10,000 --> 00:26:14,960 if i'm 627 00:26:10,799 --> 00:26:18,960 adding the website right 628 00:26:14,960 --> 00:26:20,640 good so basically you can see that i 629 00:26:18,960 --> 00:26:23,840 managed to create 630 00:26:20,640 --> 00:26:24,880 a graphql api by basically adding three 631 00:26:23,840 --> 00:26:28,960 annotations 632 00:26:24,880 --> 00:26:32,480 query type and fill which is pretty cool 633 00:26:28,960 --> 00:26:35,600 um and yeah 634 00:26:32,480 --> 00:26:37,919 let's so far i only fetched 635 00:26:35,600 --> 00:26:39,600 fields from companies so let's do some 636 00:26:37,919 --> 00:26:43,200 binding with a product 637 00:26:39,600 --> 00:26:47,600 so i'm going to go in the get products 638 00:26:43,200 --> 00:26:50,640 getter and i'm gonna add a field on it 639 00:26:47,600 --> 00:26:53,440 i'm gonna refresh the page 640 00:26:50,640 --> 00:26:55,120 and i'm getting another evolve if i'm 641 00:26:53,440 --> 00:26:57,120 zooming on this error 642 00:26:55,120 --> 00:26:58,320 it is telling me that it cannot map the 643 00:26:57,120 --> 00:27:01,600 product class 644 00:26:58,320 --> 00:27:02,640 to a known graphical type okay we 645 00:27:01,600 --> 00:27:06,000 already saw 646 00:27:02,640 --> 00:27:08,159 this error two minutes ago so i'm pretty 647 00:27:06,000 --> 00:27:09,919 sure you know what i should do i should 648 00:27:08,159 --> 00:27:12,880 go in the product class 649 00:27:09,919 --> 00:27:14,159 and instruct graphicalize that the 650 00:27:12,880 --> 00:27:17,440 product 651 00:27:14,159 --> 00:27:19,600 class is also a tie 652 00:27:17,440 --> 00:27:22,080 and so i'm putting a type here and i'm 653 00:27:19,600 --> 00:27:22,080 going to 654 00:27:22,399 --> 00:27:29,520 put a field annotation 655 00:27:26,480 --> 00:27:32,840 on the id on the name 656 00:27:29,520 --> 00:27:34,559 on the price on the margin of the 657 00:27:32,840 --> 00:27:38,559 product and 658 00:27:34,559 --> 00:27:38,559 if i'm refreshing the page 659 00:27:38,720 --> 00:27:43,360 yeah everything seems to be going great 660 00:27:40,799 --> 00:27:46,840 and i can access the products 661 00:27:43,360 --> 00:27:48,720 and access the id and the name of the 662 00:27:46,840 --> 00:27:52,320 product 663 00:27:48,720 --> 00:27:55,600 and it's working yeah 664 00:27:52,320 --> 00:27:59,200 so that's it and basically 665 00:27:55,600 --> 00:28:02,080 my job when i set up a graphql api 666 00:27:59,200 --> 00:28:02,640 becomes adding a few annotations and 667 00:28:02,080 --> 00:28:05,039 yeah 668 00:28:02,640 --> 00:28:05,039 that's it 669 00:28:05,679 --> 00:28:13,039 so yeah for the live demo 670 00:28:09,600 --> 00:28:15,520 i won't be going any further i will be 671 00:28:13,039 --> 00:28:16,080 presenting you very quickly a few 672 00:28:15,520 --> 00:28:20,000 additional 673 00:28:16,080 --> 00:28:22,240 features for instance if you want to put 674 00:28:20,000 --> 00:28:23,679 to create a mutation you have a mutation 675 00:28:22,240 --> 00:28:25,760 annotation 676 00:28:23,679 --> 00:28:27,440 that can be used to create a mutation it 677 00:28:25,760 --> 00:28:30,880 works exactly the same as 678 00:28:27,440 --> 00:28:32,799 the query annotation works 679 00:28:30,880 --> 00:28:35,279 there is a brilliant support for 680 00:28:32,799 --> 00:28:37,360 authentication and authorization 681 00:28:35,279 --> 00:28:38,480 that is plugged into your favorite 682 00:28:37,360 --> 00:28:41,600 framework 683 00:28:38,480 --> 00:28:43,440 laravel symphony whatever but basically 684 00:28:41,600 --> 00:28:47,520 if you are using the right annotation 685 00:28:43,440 --> 00:28:50,880 and passing the name of a write 686 00:28:47,520 --> 00:28:54,399 well then this query will be 687 00:28:50,880 --> 00:28:55,600 visible only if the user that is 688 00:28:54,399 --> 00:28:57,520 currently logged 689 00:28:55,600 --> 00:29:00,240 has this right you can also use the 690 00:28:57,520 --> 00:29:02,480 right annotation and feels directly 691 00:29:00,240 --> 00:29:05,039 you can even do fine-grained 692 00:29:02,480 --> 00:29:08,080 authorization 693 00:29:05,039 --> 00:29:10,000 if you want to say that some objects can 694 00:29:08,080 --> 00:29:13,760 be seen but not others 695 00:29:10,000 --> 00:29:17,039 in this example i've got an email field 696 00:29:13,760 --> 00:29:19,919 from a user and basically i am saying 697 00:29:17,039 --> 00:29:20,240 that i am looking at the component of 698 00:29:19,919 --> 00:29:23,679 the 699 00:29:20,240 --> 00:29:26,559 the user of the current user 700 00:29:23,679 --> 00:29:27,840 and comparing it with the company of the 701 00:29:26,559 --> 00:29:30,880 user that is logged 702 00:29:27,840 --> 00:29:32,320 user here refers to the user that is 703 00:29:30,880 --> 00:29:35,440 currently loaded 704 00:29:32,320 --> 00:29:37,440 and basically this is saying i can see 705 00:29:35,440 --> 00:29:39,840 the email of the people that are 706 00:29:37,440 --> 00:29:41,200 in the same company as me i can see the 707 00:29:39,840 --> 00:29:43,200 email of my colleagues 708 00:29:41,200 --> 00:29:44,880 but i cannot see the email of someone 709 00:29:43,200 --> 00:29:47,840 that is 710 00:29:44,880 --> 00:29:48,480 not my colleague so with this security 711 00:29:47,840 --> 00:29:51,039 annotation 712 00:29:48,480 --> 00:29:53,520 we can have something that is going 713 00:29:51,039 --> 00:29:56,960 quite deep 714 00:29:53,520 --> 00:29:59,919 to do fine-grained authorization 715 00:29:56,960 --> 00:30:01,200 another feature i like a lot is auto 716 00:29:59,919 --> 00:30:05,120 wiring 717 00:30:01,200 --> 00:30:08,640 uh basically here we are in a domain 718 00:30:05,120 --> 00:30:12,159 object a product and uh 719 00:30:08,640 --> 00:30:12,960 let's admit i want to compute the v80 of 720 00:30:12,159 --> 00:30:15,039 a product 721 00:30:12,960 --> 00:30:16,399 computing the v80 of a product can be 722 00:30:15,039 --> 00:30:20,000 quite complicated 723 00:30:16,399 --> 00:30:23,039 maybe i need to know uh the type of the 724 00:30:20,000 --> 00:30:26,960 product the country the 725 00:30:23,039 --> 00:30:29,840 uh the user is in so it can be difficult 726 00:30:26,960 --> 00:30:31,440 and we typically won't do it in the 727 00:30:29,840 --> 00:30:34,399 domain object but rather 728 00:30:31,440 --> 00:30:36,000 rather we will call a service but you 729 00:30:34,399 --> 00:30:39,360 when you are in a domain object 730 00:30:36,000 --> 00:30:42,480 accessing services accessing services is 731 00:30:39,360 --> 00:30:45,520 difficult and what we can do here is 732 00:30:42,480 --> 00:30:46,960 auto wire called the auto wire ring and 733 00:30:45,520 --> 00:30:47,919 basically graphic light will 734 00:30:46,960 --> 00:30:50,799 automatically 735 00:30:47,919 --> 00:30:52,480 inject when i'm calling the v80 field it 736 00:30:50,799 --> 00:30:55,360 will automatically inject 737 00:30:52,480 --> 00:30:56,080 from the dependency injection container 738 00:30:55,360 --> 00:30:59,039 the service 739 00:30:56,080 --> 00:31:01,200 the v80 service and i can use it 740 00:30:59,039 --> 00:31:05,039 directly in the resolver here 741 00:31:01,200 --> 00:31:07,360 so it enables me to access services and 742 00:31:05,039 --> 00:31:08,399 from a domain object by passing those 743 00:31:07,360 --> 00:31:10,960 services 744 00:31:08,399 --> 00:31:11,519 in parameters of the resolver which is 745 00:31:10,960 --> 00:31:15,279 kind of 746 00:31:11,519 --> 00:31:17,120 kind of cool yeah there are many many 747 00:31:15,279 --> 00:31:20,240 more features 748 00:31:17,120 --> 00:31:21,120 available uh we have support for 749 00:31:20,240 --> 00:31:23,760 validation 750 00:31:21,120 --> 00:31:24,159 uh for uh indium types even if they 751 00:31:23,760 --> 00:31:28,240 don't 752 00:31:24,159 --> 00:31:30,399 exist in php file uploads um 753 00:31:28,240 --> 00:31:31,760 what i invite you to do if you are 754 00:31:30,399 --> 00:31:34,880 interested 755 00:31:31,760 --> 00:31:38,080 in trying out graphqlite is 756 00:31:34,880 --> 00:31:41,200 having a look at the documentation 757 00:31:38,080 --> 00:31:44,559 everything is i hope clearly documented 758 00:31:41,200 --> 00:31:45,120 and if you have any issue well you can 759 00:31:44,559 --> 00:31:49,039 always 760 00:31:45,120 --> 00:31:52,480 contact me either on 761 00:31:49,039 --> 00:31:55,760 twitter directly or if you prefer 762 00:31:52,480 --> 00:31:58,960 uh just open an issue 763 00:31:55,760 --> 00:32:02,000 on the graphqlite repository yeah 764 00:31:58,960 --> 00:32:05,120 so yeah that's repetitive let's wrap uh 765 00:32:02,000 --> 00:32:08,080 this um this talk uh 766 00:32:05,120 --> 00:32:09,440 basically uh doing graphql in php is 767 00:32:08,080 --> 00:32:12,559 definitely possible 768 00:32:09,440 --> 00:32:13,200 you have many possibilities out there uh 769 00:32:12,559 --> 00:32:16,640 and this is 770 00:32:13,200 --> 00:32:19,919 since graphql is pretty cool uh 771 00:32:16,640 --> 00:32:20,960 well i definitely invite you to to try 772 00:32:19,919 --> 00:32:24,080 it out 773 00:32:20,960 --> 00:32:26,480 and uh that's it do you have any 774 00:32:24,080 --> 00:32:26,480 questions 775 00:32:27,120 --> 00:32:30,320 thanks so much david it was such 776 00:32:29,039 --> 00:32:32,640 incredible talk 777 00:32:30,320 --> 00:32:35,519 i really enjoyed it all the life current 778 00:32:32,640 --> 00:32:35,519 day we were scared 779 00:32:35,760 --> 00:32:39,440 yeah everything was incredible so that's 780 00:32:37,600 --> 00:32:43,039 great uh so yeah 781 00:32:39,440 --> 00:32:46,240 do yeah we have a question yes 782 00:32:43,039 --> 00:32:49,519 uh so florian he's asking about 783 00:32:46,240 --> 00:32:52,559 if graph graphic graph live 784 00:32:49,519 --> 00:32:55,440 is is gonna support or is currently 785 00:32:52,559 --> 00:32:57,200 supporting subscriptions 786 00:32:55,440 --> 00:32:59,919 it is not currently supporting 787 00:32:57,200 --> 00:33:03,440 subscriptions 788 00:32:59,919 --> 00:33:06,960 i plan to add support for subscriptions 789 00:33:03,440 --> 00:33:09,760 in the future maybe 790 00:33:06,960 --> 00:33:10,880 not in the in the two coming months 791 00:33:09,760 --> 00:33:14,480 because i want to 792 00:33:10,880 --> 00:33:16,880 to release a version 4.1 of graphqlite 793 00:33:14,480 --> 00:33:18,080 and i'm no subscriptions won't be part 794 00:33:16,880 --> 00:33:22,559 of this release 795 00:33:18,080 --> 00:33:24,799 but yes i would like to to work on that 796 00:33:22,559 --> 00:33:26,159 for the end of the year definitely 797 00:33:24,799 --> 00:33:28,159 definitely well that 798 00:33:26,159 --> 00:33:29,360 that's that sounds super exciting i 799 00:33:28,159 --> 00:33:31,679 guess and 800 00:33:29,360 --> 00:33:32,720 i think i have another question because 801 00:33:31,679 --> 00:33:35,360 i found 802 00:33:32,720 --> 00:33:36,559 out super super interesting so i'd like 803 00:33:35,360 --> 00:33:39,919 to understand like 804 00:33:36,559 --> 00:33:43,600 like why do you why did you decide to 805 00:33:39,919 --> 00:33:45,600 go and build this incredible technology 806 00:33:43,600 --> 00:33:48,399 and what are kind of like the future 807 00:33:45,600 --> 00:33:52,000 plans for for it 808 00:33:48,399 --> 00:33:54,559 oh okay uh um 809 00:33:52,000 --> 00:33:56,080 well when i started uh writing 810 00:33:54,559 --> 00:34:00,000 graphically light it was 811 00:33:56,080 --> 00:34:02,640 two years ago and basically you had only 812 00:34:00,000 --> 00:34:04,559 two options at the time it was using 813 00:34:02,640 --> 00:34:06,480 webonix directly 814 00:34:04,559 --> 00:34:08,720 or uh using um 815 00:34:06,480 --> 00:34:10,879 [Music] 816 00:34:08,720 --> 00:34:12,320 using ushido which is a library that has 817 00:34:10,879 --> 00:34:14,159 been abandoned 818 00:34:12,320 --> 00:34:18,000 and basically they were really low level 819 00:34:14,159 --> 00:34:18,000 libraries and they were hard to use 820 00:34:18,079 --> 00:34:21,919 and i have this huge project for a 821 00:34:20,480 --> 00:34:24,079 client of mine 822 00:34:21,919 --> 00:34:27,119 uh we are just at the coding machine we 823 00:34:24,079 --> 00:34:30,800 are doing mostly internet and extranet 824 00:34:27,119 --> 00:34:35,200 applications and a client of mine 825 00:34:30,800 --> 00:34:37,200 uh had uh this huge rest api 826 00:34:35,200 --> 00:34:38,879 with a lot of end points and maybe read 827 00:34:37,200 --> 00:34:41,760 on the end points 828 00:34:38,879 --> 00:34:42,240 i wanted to do graphql because i knew 829 00:34:41,760 --> 00:34:44,560 that 830 00:34:42,240 --> 00:34:46,240 the flexibility of graph create would be 831 00:34:44,560 --> 00:34:49,440 really really beneficial 832 00:34:46,240 --> 00:34:50,960 for that client and uh the only option i 833 00:34:49,440 --> 00:34:55,200 had was webonix which was 834 00:34:50,960 --> 00:34:57,599 too hard to use uh and so i decided 835 00:34:55,200 --> 00:35:00,880 i started writing a small library which 836 00:34:57,599 --> 00:35:04,240 became a bit more complex 837 00:35:00,880 --> 00:35:05,599 and uh i did two three versions of the 838 00:35:04,240 --> 00:35:09,200 library and then i 839 00:35:05,599 --> 00:35:09,440 i told myself okay uh i i must work on 840 00:35:09,200 --> 00:35:12,560 it 841 00:35:09,440 --> 00:35:14,640 really seriously put it on um 842 00:35:12,560 --> 00:35:15,760 open source it and well that's how 843 00:35:14,640 --> 00:35:19,040 graphic light 844 00:35:15,760 --> 00:35:19,599 was born actually well that sounds that 845 00:35:19,040 --> 00:35:22,000 sounds 846 00:35:19,599 --> 00:35:22,720 so great and i think like thanks so much 847 00:35:22,000 --> 00:35:24,400 for 848 00:35:22,720 --> 00:35:26,400 contributing with the graphql community 849 00:35:24,400 --> 00:35:27,839 in this case in the php because 850 00:35:26,400 --> 00:35:30,000 yeah i think there are not so many 851 00:35:27,839 --> 00:35:33,200 people that either they don't know that 852 00:35:30,000 --> 00:35:34,880 they are able to do these or they 853 00:35:33,200 --> 00:35:36,320 figure out they like realize that it's a 854 00:35:34,880 --> 00:35:38,480 bit more difficult so it's even like a 855 00:35:36,320 --> 00:35:42,160 start you know like to contribute so 856 00:35:38,480 --> 00:35:44,560 i i i think like like like this is super 857 00:35:42,160 --> 00:35:46,800 super super interested and i think like 858 00:35:44,560 --> 00:35:48,240 a if the people they do know this 859 00:35:46,800 --> 00:35:48,560 library they are going to start to use 860 00:35:48,240 --> 00:35:50,000 it 861 00:35:48,560 --> 00:35:52,079 they are going to like it and they are 862 00:35:50,000 --> 00:35:54,320 going to like adopting their company so 863 00:35:52,079 --> 00:35:55,839 um yeah thanks so much for sharing this 864 00:35:54,320 --> 00:35:58,640 knowledge with us 865 00:35:55,839 --> 00:35:58,640 you're welcome yeah 866 00:35:58,960 --> 00:36:02,320 yeah thanks so much for like like like 867 00:36:00,960 --> 00:36:04,400 like contacting us to 868 00:36:02,320 --> 00:36:05,440 speak uh because it's it's been 869 00:36:04,400 --> 00:36:06,880 difficult to find 870 00:36:05,440 --> 00:36:08,320 kind of like people that they have 871 00:36:06,880 --> 00:36:09,760 companies in hong kong although you are 872 00:36:08,320 --> 00:36:11,280 not in hong kong right now but i 873 00:36:09,760 --> 00:36:12,800 you're like really connected to the hong 874 00:36:11,280 --> 00:36:15,760 kong community so 875 00:36:12,800 --> 00:36:16,720 i am so so glad to have you here and 876 00:36:15,760 --> 00:36:20,000 thanks so much and 877 00:36:16,720 --> 00:36:23,440 i really really hope to see you soon 878 00:36:20,000 --> 00:36:27,200 thank you very much okay david thanks 879 00:36:23,440 --> 00:36:27,200 so up next so