Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/globaz/prod_global4net_com/wp-config.php:1) in /usr/www/users/globaz/prod_global4net_com/wp-content/plugins/handl-utm-grabber-v3/handl-utm-grabber-v3.php on line 269

Warning: Undefined array key "HandLtestDomainNameServer" in /usr/www/users/globaz/prod_global4net_com/wp-content/plugins/handl-utm-grabber-v3/handl-utm-grabber-v3.php on line 303

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/globaz/prod_global4net_com/wp-config.php:1) in /usr/www/users/globaz/prod_global4net_com/wp-content/plugins/handl-utm-grabber-v3/handl-utm-grabber-v3.php on line 219

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/globaz/prod_global4net_com/wp-config.php:1) in /usr/www/users/globaz/prod_global4net_com/wp-content/plugins/handl-utm-grabber-v3/handl-utm-grabber-v3.php on line 219

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/globaz/prod_global4net_com/wp-config.php:1) in /usr/www/users/globaz/prod_global4net_com/wp-content/plugins/handl-utm-grabber-v3/handl-utm-grabber-v3.php on line 219

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/globaz/prod_global4net_com/wp-config.php:1) in /usr/www/users/globaz/prod_global4net_com/wp-content/plugins/handl-utm-grabber-v3/handl-utm-grabber-v3.php on line 219

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/globaz/prod_global4net_com/wp-config.php:1) in /usr/www/users/globaz/prod_global4net_com/wp-content/plugins/handl-utm-grabber-v3/handl-utm-grabber-v3.php on line 219

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/globaz/prod_global4net_com/wp-config.php:1) in /usr/www/users/globaz/prod_global4net_com/wp-content/plugins/handl-utm-grabber-v3/handl-utm-grabber-v3.php on line 269

Warning: Undefined array key "HandLtestDomainNameServer" in /usr/www/users/globaz/prod_global4net_com/wp-content/plugins/handl-utm-grabber-v3/handl-utm-grabber-v3.php on line 303

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/globaz/prod_global4net_com/wp-config.php:1) in /usr/www/users/globaz/prod_global4net_com/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/globaz/prod_global4net_com/wp-config.php:1) in /usr/www/users/globaz/prod_global4net_com/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/globaz/prod_global4net_com/wp-config.php:1) in /usr/www/users/globaz/prod_global4net_com/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/globaz/prod_global4net_com/wp-config.php:1) in /usr/www/users/globaz/prod_global4net_com/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/globaz/prod_global4net_com/wp-config.php:1) in /usr/www/users/globaz/prod_global4net_com/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/globaz/prod_global4net_com/wp-config.php:1) in /usr/www/users/globaz/prod_global4net_com/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/globaz/prod_global4net_com/wp-config.php:1) in /usr/www/users/globaz/prod_global4net_com/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/globaz/prod_global4net_com/wp-config.php:1) in /usr/www/users/globaz/prod_global4net_com/wp-includes/rest-api/class-wp-rest-server.php on line 1831
{"id":6294,"date":"2021-06-08T16:44:56","date_gmt":"2021-06-08T14:44:56","guid":{"rendered":"https:\/\/global4net.com\/?p=6294"},"modified":"2023-11-10T14:31:08","modified_gmt":"2023-11-10T13:31:08","slug":"magento-2-optymalizacja-aplikacji-z-graphql","status":"publish","type":"post","link":"https:\/\/global4net.com\/blog\/magento\/magento-2-optymalizacja-aplikacji-z-graphql\/","title":{"rendered":"Magento 2: Optymalizacja aplikacji z GraphQL"},"content":{"rendered":"

Je\u015bli mieliby\u015bmy wyci\u0105gn\u0105\u0107 jak\u0105\u015b nauk\u0119 z dziedziny IT z pewno\u015bci\u0105 dotyczy\u0142aby ona tego, \u017ce ka\u017cde rozwi\u0105zanie zawsze mo\u017cna usprawni\u0107. Nie zawsze b\u0119dzie to du\u017ca zmiana, ale niemniej Twoje rozwi\u0105zanie stanie si\u0119 bardziej zoptymalizowane. Post\u0119p w IT nie nast\u0119puje w paru du\u017cych skokach wydajno\u015bci. Przewa\u017caj\u0105c\u0105 norm\u0105 jest cierpliwy, ale pewny i nieust\u0119puj\u0105cy post\u0119p \u2013 to on pcha bran\u017c\u0119 informatyczn\u0105 do przodu. Jest to wyj\u0105tkowo widoczne przy optymalizacji platform e-Commerce’owych. Do najpopularniejszych z nich nale\u017cy Magento<\/strong> i po przeczytaniu tego artyku\u0142u dowiesz si\u0119 jak optymalizowa\u0107 zapytania w Magento 2 z u\u017cyciem GraphQL<\/strong>.<\/p>\n

Jak optymalizowa\u0107 komunikacj\u0119 server-client w Magento 2 z GraphQL-em?<\/h2>\n

Magento 2<\/a><\/strong> jest platform\u0105 e-Commerce wykorzystywan\u0105 przez profesjonalist\u00f3w do budowania i utrzymania sklep\u00f3w internetowych. Ka\u017cdy zna powiedzenie “klient nasz pan” i podobnie jest w e-handlu: kluczowym elementem jest satysfakcja klienta, dlatego te\u017c w\u0142a\u015bciciele e-Commerce stawiaj\u0105 na maksymaln\u0105 optymalizacj\u0119<\/strong> do\u015bwiadcze\u0144. To w\u0142a\u015bnie mi\u0119dzy wygod\u0105 korzystania ze strony i klientem wchodzi kwestia technologii GraphQL. Ale na jakie sposoby optymalizuje ona komunikacj\u0119 w Magento 2?<\/p>\n

Czym jest GraphQL?<\/h3>\n

GraphQL jest j\u0119zykiem zapyta\u0144 dla system\u00f3w API udost\u0119pnianym na prawach licencji Open Source. J\u0119zyk ten zosta\u0142 stworzony przez Facebooka w 2012 roku a obecnie jest wspierany przez GraphQL Foundation<\/a><\/strong>. W\u0142a\u015bciciele Facebooka wraz z innymi organizacjami zwi\u0105zanymi z IT powo\u0142ali t\u0119 fundacj\u0119, aby rozwija\u0107 technologie zgodnie z zasadami non-profit. W wyniku tych dzia\u0142a\u0144 wok\u00f3\u0142 GraphQL-a zacz\u0119\u0142a skupia\u0107 si\u0119 coraz wi\u0119ksza spo\u0142eczno\u015b\u0107 developer\u00f3w. Dzisiaj jest jednym z popularniejszych j\u0119zyk\u00f3w do obs\u0142ugi zapyta\u0144. Zalicza si\u0119 do niego wiele bibliotek pozwalaj\u0105cych na obs\u0142ug\u0119 tego j\u0119zyka, zar\u00f3wno po stronie serwerowej, jak i po stronie klienta. Dwie z bibliotek GraphQL wchodz\u0105 w sk\u0142ad stacku technoloczniego Magento 2 i s\u0142u\u017c\u0105 optymalizacji backendu i frontendu<\/strong>. S\u0105 to w<\/strong>ebonyx\/graphql-php<\/strong> (server-side) i Apollo Graphql Nano<\/strong> (client-side).<\/p>\n

\"programista<\/a><\/p>\n

Jak dzia\u0142a GraphQL?<\/h3>\n

GraphQL u\u017cywa zapyta\u0144 query, aby w wydajny i elastyczny spos\u00f3b pozyskiwa\u0107 dane, kt\u00f3re s\u0105 pobierane w odpowiedzi na konkretne akcj\u0119 u\u017cytkownika. System wysy\u0142a zapytania w protokole HTTP i HTTPS i uzyskuje odpowiedzi na nie w formacie JSON \u2013 <\/strong>j\u0119zyku opartym na JavaScript stworzonym pod zadania zwi\u0105zane z wymian\u0105 danych. Zanim wy\u015blemy zapytanie query musisz si\u0119 upewni\u0107, \u017ce jest ono zgodne ze zdefiniowanym schematem dzia\u0142aj\u0105cym po stronie serwera. Dodatkowo w GraphQL w\u0142a\u015bciwo\u015bci danych pobieranych z backendu zale\u017c\u0105 od wys\u0142anego zapytania:<\/p>\n