{"id":36575,"date":"2025-12-20T03:40:43","date_gmt":"2025-12-20T00:40:43","guid":{"rendered":"https:\/\/fatihsoysal.com\/blog\/?p=36575"},"modified":"2025-12-20T03:40:43","modified_gmt":"2025-12-20T00:40:43","slug":"intro-to-graphql-in-react-using-react-apollo-apollo-boost","status":"publish","type":"post","link":"https:\/\/fatihsoysal.com\/blog\/intro-to-graphql-in-react-using-react-apollo-apollo-boost\/","title":{"rendered":"Intro to GraphQL in React Using React Apollo &#038; Apollo Boost"},"content":{"rendered":"<p><body><\/p>\n<h2>Intro to GraphQL in React Using React Apollo &#038; Apollo Boost<\/h2>\n<h2>Giri\u015f<\/h2>\n<p>Modern web uygulamalar\u0131, kullan\u0131c\u0131lar\u0131na zengin ve dinamik deneyimler sunmak i\u00e7in s\u00fcrekli olarak daha verimli ve esnek veri al\u0131\u015fveri\u015fi y\u00f6ntemlerine ihtiya\u00e7 duyar. Bu ba\u011flamda, Facebook taraf\u0131ndan geli\u015ftirilen GraphQL, API geli\u015ftirmeye ve kullanmaya y\u00f6nelik devrim niteli\u011finde bir yakla\u015f\u0131m sunmaktad\u0131r. Geleneksel REST mimarisine k\u0131yasla daha g\u00fc\u00e7l\u00fc ve esnek bir alternatif olarak ortaya \u00e7\u0131kan GraphQL, \u00f6zellikle React gibi component tabanl\u0131 kullan\u0131c\u0131 aray\u00fcz\u00fc k\u00fct\u00fcphaneleriyle birle\u015fti\u011finde, geli\u015ftiricilere e\u015fsiz bir verimlilik ve kontrol sa\u011flar.<\/p>\n<p>Bu makalede, React uygulamalar\u0131n\u0131zda GraphQL&#8217;i nas\u0131l kullanaca\u011f\u0131n\u0131z\u0131, \u00f6zellikle de Apollo Client ekosistemini (React Apollo ve Apollo Boost&#8217;un modern kar\u015f\u0131l\u0131\u011f\u0131 olan <code>@apollo\/client<\/code> paketi) derinlemesine inceleyece\u011fiz. GraphQL&#8217;in temel prensiplerinden ba\u015flayarak, bir React uygulamas\u0131nda veri sorgulama, de\u011fi\u015ftirme ve hatta ger\u00e7ek zamanl\u0131 g\u00fcncellemeler yapma s\u00fcre\u00e7lerini ad\u0131m ad\u0131m ele alaca\u011f\u0131z. Amac\u0131m\u0131z, bu g\u00fc\u00e7l\u00fc teknolojileri bir araya getirerek modern ve performansl\u0131 React uygulamalar\u0131 geli\u015ftirmek i\u00e7in sa\u011flam bir temel olu\u015fturmakt\u0131r.<\/p>\n<h3>GraphQL Nedir ve Neden \u00d6nemlidir?<\/h3>\n<p>GraphQL, API&#8217;ler i\u00e7in bir sorgulama dili ve \u00e7al\u0131\u015fma zaman\u0131 ortam\u0131d\u0131r. Geleneksel REST API&#8217;lerinin aksine, GraphQL ile istemci tam olarak hangi veriye ihtiyac\u0131 oldu\u011funu belirtebilir ve sunucu da sadece o veriyi d\u00f6nd\u00fcr\u00fcr. Bu, <code>under-fetching<\/code> (gere\u011finden az veri \u00e7ekme) ve <code>over-fetching<\/code> (gere\u011finden fazla veri \u00e7ekme) gibi sorunlar\u0131 ortadan kald\u0131r\u0131r.<\/p>\n<p>*   <strong>Under-fetching:<\/strong> REST API&#8217;lerinde, tek bir endpoint \u00fczerinden istenen t\u00fcm veriler al\u0131namayabilir. \u00d6rne\u011fin, bir kullan\u0131c\u0131n\u0131n bilgilerini ve o kullan\u0131c\u0131n\u0131n t\u00fcm sipari\u015flerini almak i\u00e7in iki ayr\u0131 istek yapmak gerekebilir.<br \/>\n*   <strong>Over-fetching:<\/strong> Bir endpoint, istemcinin ihtiyac\u0131ndan daha fazla veri d\u00f6nd\u00fcrebilir. Bu durum, \u00f6zellikle mobil cihazlarda bant geni\u015fli\u011fi ve performans sorunlar\u0131na yol a\u00e7abilir.<\/p>\n<p>GraphQL, tek bir endpoint \u00fczerinden, istemcinin belirtti\u011fi karma\u015f\u0131k veri yap\u0131lar\u0131n\u0131 sorgulama yetene\u011fi sunar. Bu, a\u011f isteklerinin say\u0131s\u0131n\u0131 azalt\u0131r, veri transferini optimize eder ve istemci taraf\u0131nda veri i\u015fleme mant\u0131\u011f\u0131n\u0131 basitle\u015ftirir. Ayr\u0131ca, g\u00fc\u00e7l\u00fc bir tip sistemi sayesinde API&#8217;nizin t\u00fcm yetenekleri ve veri yap\u0131s\u0131 net bir \u015fekilde tan\u0131mlan\u0131r, bu da istemci ve sunucu aras\u0131nda daha iyi bir ileti\u015fim ve hata ay\u0131klama deneyimi sa\u011flar.<\/p>\n<h3>Apollo Client Ekosistemi<\/h3>\n<p>React uygulamalar\u0131nda GraphQL ile etkile\u015fime girmek i\u00e7in bir\u00e7ok k\u00fct\u00fcphane bulunmaktad\u0131r. Bunlar aras\u0131nda en pop\u00fcler ve kapsaml\u0131 olan\u0131 Apollo Client&#8217;t\u0131r. Apollo Client, React uygulamalar\u0131nda GraphQL sorgular\u0131, mutasyonlar\u0131 ve aboneliklerini y\u00f6netmek i\u00e7in bir dizi ara\u00e7 ve \u00f6zellik sunar. \u00d6nbellekleme, durum y\u00f6netimi, hata y\u00f6netimi ve UI entegrasyonu gibi konularda geli\u015ftiricilere b\u00fcy\u00fck kolayl\u0131klar sa\u011flar.<\/p>\n<p>Ba\u015flang\u0131\u00e7ta Apollo Client kurulumu i\u00e7in <code>apollo-boost<\/code> ad\u0131nda bir paket mevcuttu. Bu paket, temel Apollo Client kurulumunu &#8220;s\u0131f\u0131r konfig\u00fcrasyon&#8221; yakla\u015f\u0131m\u0131yla basitle\u015ftirmeyi ama\u00e7l\u0131yordu. Ancak zamanla, Apollo Client&#8217;\u0131n ana paketi olan <code>@apollo\/client<\/code>, bu kolayl\u0131klar\u0131 kendi i\u00e7ine entegre etti ve <code>apollo-boost<\/code> paketi art\u0131k ayr\u0131 bir ba\u011f\u0131ml\u0131l\u0131k olarak kullan\u0131lmamaktad\u0131r. G\u00fcn\u00fcm\u00fczde, <code>@apollo\/client<\/code> paketi hem temel Apollo Client i\u015flevselli\u011fini hem de basit kurulum kolayl\u0131klar\u0131n\u0131 tek bir \u00e7at\u0131 alt\u0131nda sunmaktad\u0131r. Bu makalede de g\u00fcncel yakla\u015f\u0131ma uygun olarak <code>@apollo\/client<\/code> paketini kullanarak \u00f6rnekler verece\u011fiz.<\/p>\n<h2>GraphQL Temelleri<\/h2>\n<p>React uygulamalar\u0131nda GraphQL kullanmaya ba\u015flamadan \u00f6nce, GraphQL&#8217;in temel yap\u0131 ta\u015flar\u0131n\u0131 anlamak \u00f6nemlidir.<\/p>\n<h3>Schema (\u015eema) ve Type System (Tip Sistemi)<\/h3>\n<p>GraphQL&#8217;in kalbinde \u015fema ve tip sistemi bulunur. \u015eema, API&#8217;nizin hangi verileri sorgulayabilece\u011finizi, de\u011fi\u015ftirebilece\u011finizi ve hangi tiplere sahip olduklar\u0131n\u0131 tan\u0131mlayan bir s\u00f6zle\u015fmedir. Her GraphQL API&#8217;sinin bir \u015femas\u0131 vard\u0131r. Bu \u015fema, API&#8217;nin istemciye sundu\u011fu t\u00fcm veri tiplerini, alanlar\u0131n\u0131 ve operasyonlar\u0131n\u0131 belirtir.<\/p>\n<p>*   <strong>Object Types (Nesne Tipleri):<\/strong> Uygulaman\u0131zdaki veri nesnelerini temsil eder. \u00d6rne\u011fin, bir <code>User<\/code> veya <code>Product<\/code> tipi.<br \/>\n*   <strong>Fields (Alanlar):<\/strong> Bir nesne tipinin sahip oldu\u011fu \u00f6zelliklerdir. \u00d6rne\u011fin, <code>User<\/code> tipinin <code>id<\/code>, <code>name<\/code>, <code>email<\/code> gibi alanlar\u0131 olabilir.<br \/>\n*   <strong>Scalar Types (Skaler Tipler):<\/strong> Temel veri tipleridir (String, Int, Float, Boolean, ID).<br \/>\n*   <strong>Enums (Numaraland\u0131rmalar):<\/strong> Belirli bir de\u011fer k\u00fcmesinden birini alabilen tiplerdir.<br \/>\n*   <strong>Input Types (Girdi Tipleri):<\/strong> Mutasyonlara g\u00f6nderilen verilerin yap\u0131s\u0131n\u0131 tan\u0131mlamak i\u00e7in kullan\u0131l\u0131r.<br \/>\n*   <strong>Interface (Aray\u00fcz) ve Union (Birle\u015fim):<\/strong> Polimorfik veri yap\u0131lar\u0131 olu\u015fturmak i\u00e7in kullan\u0131l\u0131r.<\/p>\n<p>\u00d6rnek bir GraphQL \u015femas\u0131 tan\u0131m\u0131 (sunucu taraf\u0131nda):<\/p>\n<pre><code class=\"language-graphql\">type Product {\n  id: ID!\n  name: String!\n  description: String\n  price: Float!\n  category: Category\n}\n\ntype Category {\n  id: ID!\n  name: String!\n  products: [Product]\n}\n\ntype Query {\n  products: [Product]\n  product(id: ID!): Product\n  categories: [Category]\n}\n\ntype Mutation {\n  addProduct(name: String!, description: String, price: Float!, categoryId: ID!): Product\n  updateProduct(id: ID!, name: String, description: String, price: Float, categoryId: ID): Product\n  deleteProduct(id: ID!): Boolean\n}<\/code><\/pre>\n<p>Bu \u015fema, <code>Product<\/code> ve <code>Category<\/code> ad\u0131nda iki nesne tipi, bu tiplerin alanlar\u0131 ve <code>Query<\/code> ile <code>Mutation<\/code> operasyonlar\u0131n\u0131n nas\u0131l yap\u0131laca\u011f\u0131n\u0131 tan\u0131mlar. <code>Query<\/code> tipi veri okuma operasyonlar\u0131n\u0131, <code>Mutation<\/code> tipi ise veri yazma (olu\u015fturma, g\u00fcncelleme, silme) operasyonlar\u0131n\u0131 temsil eder.<\/p>\n<h3>Query (Sorgu)<\/h3>\n<p>GraphQL&#8217;de veri okumak i\u00e7in sorgular kullan\u0131l\u0131r. \u0130stemci, sunucudan tam olarak hangi alanlara ihtiyac\u0131 oldu\u011funu belirterek bir sorgu g\u00f6nderir.<\/p>\n<pre><code class=\"language-graphql\">query GetProductList {\n  products {\n    id\n    name\n    price\n    category {\n      name\n    }\n  }\n}<\/code><\/pre>\n<p>Bu sorgu, t\u00fcm \u00fcr\u00fcnlerin <code>id<\/code>, <code>name<\/code>, <code>price<\/code> alanlar\u0131n\u0131 ve ili\u015fkili kategorinin <code>name<\/code> alan\u0131n\u0131 isteyecektir.<\/p>\n<p>De\u011fi\u015fkenlerle sorgu yapmak:<\/p>\n<pre><code class=\"language-graphql\">query GetProductById($productId: ID!) {\n  product(id: $productId) {\n    id\n    name\n    description\n    price\n  }\n}<\/code><\/pre>\n<p>Bu sorgu, <code>$productId<\/code> de\u011fi\u015fkeni ile belirli bir \u00fcr\u00fcn\u00fc getirir. <code>!<\/code> i\u015fareti, de\u011fi\u015fkenin zorunlu oldu\u011funu g\u00f6sterir.<\/p>\n<h3>Mutation (De\u011fi\u015fiklik)<\/h3>\n<p>Veri olu\u015fturmak, g\u00fcncellemek veya silmek i\u00e7in mutasyonlar kullan\u0131l\u0131r. Mutasyonlar, sorgulara benzer bir yap\u0131ya sahiptir ancak veri \u00fczerinde bir de\u011fi\u015fiklik yapma amac\u0131 ta\u015f\u0131rlar.<\/p>\n<pre><code class=\"language-graphql\">mutation AddNewProduct($name: String!, $description: String, $price: Float!, $categoryId: ID!) {\n  addProduct(name: $name, description: $description, price: $price, categoryId: $categoryId) {\n    id\n    name\n    price\n  }\n}<\/code><\/pre>\n<p>Bu mutasyon, yeni bir \u00fcr\u00fcn ekler ve eklenen \u00fcr\u00fcn\u00fcn <code>id<\/code>, <code>name<\/code> ve <code>price<\/code> alanlar\u0131n\u0131 d\u00f6nd\u00fcr\u00fcr.<\/p>\n<h3>Subscription (Abonelik)<\/h3>\n<p>GraphQL abonelikleri, istemcinin sunucudan ger\u00e7ek zamanl\u0131 g\u00fcncellemeler almas\u0131n\u0131 sa\u011flar. Bir olay meydana geldi\u011finde (\u00f6rne\u011fin, yeni bir mesaj g\u00f6nderildi\u011finde), sunucu istemciye veri g\u00f6nderir. Bu genellikle WebSocket ba\u011flant\u0131lar\u0131 \u00fczerinden ger\u00e7ekle\u015ftirilir.<\/p>\n<pre><code class=\"language-graphql\">subscription OnProductAdded {\n  productAdded {\n    id\n    name\n    price\n  }\n}<\/code><\/pre>\n<p>Bu abonelik, her yeni \u00fcr\u00fcn eklendi\u011finde <code>productAdded<\/code> olay\u0131n\u0131 dinler ve eklenen \u00fcr\u00fcn\u00fcn bilgilerini al\u0131r.<\/p>\n<h2>Apollo Client Nedir?<\/h2>\n<p>Apollo Client, GraphQL API&#8217;leri ile etkile\u015fim kurmak i\u00e7in kapsaml\u0131 bir istemci taraf\u0131 k\u00fct\u00fcphanesidir. React, Vue, Angular gibi \u00e7e\u015fitli UI k\u00fct\u00fcphaneleriyle entegre olabilir. Temel \u00f6zellikleri \u015funlard\u0131r:<\/p>\n<p>*   <strong>Veri \u00c7ekme ve Y\u00f6netimi:<\/strong> GraphQL sorgular\u0131n\u0131 ve mutasyonlar\u0131n\u0131 kolayca yapman\u0131z\u0131 sa\u011flar.<br \/>\n*   <strong>\u00d6nbellekleme:<\/strong> \u00c7ekilen verileri otomatik olarak \u00f6nbelle\u011fe al\u0131r, b\u00f6ylece ayn\u0131 veriler i\u00e7in tekrar a\u011f iste\u011fi yap\u0131lmas\u0131na gerek kalmaz. Bu, uygulaman\u0131n performans\u0131n\u0131 \u00f6nemli \u00f6l\u00e7\u00fcde art\u0131r\u0131r.<br \/>\n*   <strong>Durum Y\u00f6netimi:<\/strong> Uygulaman\u0131z\u0131n yerel durumunu GraphQL verileriyle birlikte y\u00f6netmenizi sa\u011flar.<br \/>\n*   <strong>Hata Y\u00f6netimi:<\/strong> A\u011f ve GraphQL hatalar\u0131n\u0131 kolayca yakalaman\u0131z\u0131 ve i\u015flemenizi sa\u011flar.<br \/>\n*   <strong>Ger\u00e7ek Zamanl\u0131 G\u00fcncellemeler:<\/strong> Abonelikler arac\u0131l\u0131\u011f\u0131yla ger\u00e7ek zamanl\u0131 veri ak\u0131\u015f\u0131n\u0131 destekler.<br \/>\n*   <strong>UI Entegrasyonu:<\/strong> React gibi UI k\u00fct\u00fcphaneleri i\u00e7in \u00f6zel Hook&#8217;lar ve bile\u015fenler sunar, bu da veri ba\u011flamay\u0131 ve UI g\u00fcncellemelerini basitle\u015ftirir.<\/p>\n<p>Apollo Client, sadece bir veri \u00e7ekme k\u00fct\u00fcphanesi olman\u0131n \u00f6tesinde, uygulaman\u0131z\u0131n veri katman\u0131n\u0131 y\u00f6netmek i\u00e7in g\u00fc\u00e7l\u00fc bir \u00e7\u00f6z\u00fcm sunar.<\/p>\n<h2>React Apollo ve Apollo Boost Kurulumu<\/h2>\n<p>Modern React uygulamalar\u0131nda Apollo Client kullanmak i\u00e7in <code>@apollo\/client<\/code> paketini kurman\u0131z yeterlidir. Bu paket, eski <code>apollo-boost<\/code> paketinin t\u00fcm kolayl\u0131klar\u0131n\u0131 ve Apollo Client&#8217;\u0131n t\u00fcm g\u00fcc\u00fcn\u00fc birle\u015ftirir.<\/p>\n<h3>Gereksinimler<\/h3>\n<p>*   Node.js ve npm\/yarn kurulu olmal\u0131.<br \/>\n*   Yeni veya mevcut bir React projesi (Create React App veya Vite ile olu\u015fturulmu\u015f olabilir).<\/p>\n<h3>Kurulum Ad\u0131mlar\u0131<\/h3>\n<p>React projenizin k\u00f6k dizininde a\u015fa\u011f\u0131daki komutu \u00e7al\u0131\u015ft\u0131rarak <code>@apollo\/client<\/code> ve <code>graphql<\/code> paketlerini kurun:<\/p>\n<pre><code class=\"language-bash\">npm install @apollo\/client graphql\n<h2>veya<\/h2>\nyarn add @apollo\/client graphql<\/code><\/pre>\n<p><code>graphql<\/code> paketi, sorgular\u0131 ayr\u0131\u015ft\u0131rmak (parse etmek) i\u00e7in gereklidir.<\/p>\n<h3>ApolloClient \u00d6rne\u011fi Olu\u015fturma<\/h3>\n<p>Uygulaman\u0131z\u0131n <code>src\/index.js<\/code> veya <code>src\/App.js<\/code> dosyas\u0131nda, bir <code>ApolloClient<\/code> \u00f6rne\u011fi olu\u015fturman\u0131z gerekir. Bu \u00f6rnek, GraphQL sunucunuzun adresini ve \u00f6nbellekleme stratejilerini i\u00e7erecektir.<\/p>\n<pre><code class=\"language-javascript\">\/\/ src\/index.js veya src\/App.js\nimport React from 'react';\nimport ReactDOM from 'react-dom\/client';\nimport App from '.\/App';\nimport { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo\/client';\n\n\/\/ GraphQL sunucunuzun URI'sini belirtin\nconst client = new ApolloClient({\n  uri: 'http:\/\/localhost:4000\/graphql', \/\/ Kendi GraphQL sunucu adresinizle de\u011fi\u015ftirin\n  cache: new InMemoryCache(), \/\/ \u00d6nbellekleme i\u00e7in InMemoryCache kullan\u0131n\n});\n\nconst root = ReactDOM.createRoot(document.getElementById('root'));\nroot.render(\n  <React.StrictMode>\n    <ApolloProvider client={client}>\n      <App \/>\n    <\/ApolloProvider>\n  <\/React.StrictMode>\n);<\/code><\/pre>\n<h3>ApolloProvider ile React Uygulamas\u0131na Entegrasyon<\/h3>\n<p><code>ApolloProvider<\/code> bile\u015feni, <code>ApolloClient<\/code> \u00f6rne\u011fini React component a\u011fac\u0131na sa\u011flar. Bu sayede, alt\u0131ndaki t\u00fcm React bile\u015fenleri <code>useQuery<\/code>, <code>useMutation<\/code> ve <code>useSubscription<\/code> gibi Apollo Hook&#8217;lar\u0131na eri\u015febilir. Uygulaman\u0131z\u0131n en \u00fcst seviyesinde (<code>App<\/code> bile\u015feninin sarmalay\u0131c\u0131s\u0131 olarak) <code>ApolloProvider<\/code>&#8216;\u0131 kullanmak en yayg\u0131n yakla\u015f\u0131md\u0131r.<\/p>\n<p>Bu kurulumla birlikte, React uygulaman\u0131z art\u0131k GraphQL API&#8217;nizle ileti\u015fim kurmaya haz\u0131r hale gelmi\u015ftir.<\/p>\n<h2>GraphQL Sorgular\u0131 Yapma (useQuery)<\/h2>\n<p>Apollo Client&#8217;\u0131n <code>useQuery<\/code> Hook&#8217;u, React bile\u015fenlerinizden GraphQL sorgular\u0131 yapman\u0131n birincil yoludur. Bu Hook, sorgunun durumunu (y\u00fckleniyor, hata var, veri geldi) y\u00f6netir ve bile\u015feninizi otomatik olarak g\u00fcnceller.<\/p>\n<h3>useQuery Hook&#8217;unun Kullan\u0131m\u0131<\/h3>\n<p><code>useQuery<\/code> Hook&#8217;u, bir GraphQL sorgu dizesi (template literal i\u00e7inde) al\u0131r ve bir nesne d\u00f6nd\u00fcr\u00fcr. Bu nesne genellikle \u00fc\u00e7 \u00f6nemli \u00f6zellik i\u00e7erir: <code>loading<\/code>, <code>error<\/code> ve <code>data<\/code>.<\/p>\n<pre><code class=\"language-javascript\">import React from 'react';\nimport { gql, useQuery } from '@apollo\/client';\n\n\/\/ GraphQL sorgusunu tan\u0131mlay\u0131n\nconst GET_PRODUCTS = gql<code>\n  query GetProducts {\n    products {\n      id\n      name\n      price\n      category {\n        name\n      }\n    }\n  }\n<\/code>;\n\nfunction ProductsList() {\n  const { loading, error, data } = useQuery(GET_PRODUCTS);\n\n  if (loading) return <p>\u00dcr\u00fcnler y\u00fckleniyor...<\/p>;\n  if (error) return <p>Hata olu\u015ftu: {error.message}<\/p>;\n\n  return (\n    <div>\n      <h2>\u00dcr\u00fcn Listesi<\/h2>\n      {data.products.map(product => (\n        <div key={product.id}>\n          <h3>{product.name}<\/h3>\n          <p>Fiyat: {product.price} TL<\/p>\n          <p>Kategori: {product.category?.name}<\/p>\n        <\/div>\n      ))}\n    <\/div>\n  );\n}\n\nexport default ProductsList;<\/code><\/pre>\n<p>Bu \u00f6rnekte:<br \/>\n*   <code>GET_PRODUCTS<\/code> sabiti, <code>gql<\/code> template literal etiketi kullan\u0131larak GraphQL sorgusunu tan\u0131mlar. Bu etiket, sorguyu ayr\u0131\u015ft\u0131r\u0131r ve Apollo Client&#8217;\u0131n anlayabilece\u011fi bir formata d\u00f6n\u00fc\u015ft\u00fcr\u00fcr.<br \/>\n*   <code>useQuery(GET_PRODUCTS)<\/code> \u00e7a\u011fr\u0131s\u0131, sorguyu yapar ve <code>loading<\/code>, <code>error<\/code>, <code>data<\/code> durumlar\u0131n\u0131 d\u00f6nd\u00fcr\u00fcr.<br \/>\n*   <code>loading<\/code> do\u011fru oldu\u011funda, bir y\u00fckleme mesaj\u0131 g\u00f6sterilir.<br \/>\n*   <code>error<\/code> varsa, bir hata mesaj\u0131 g\u00f6sterilir.<br \/>\n*   <code>data<\/code> geldi\u011finde, \u00fcr\u00fcn listesi render edilir.<\/p>\n<h3>De\u011fi\u015fkenlerle Sorgu Yapma<\/h3>\n<p>Sorgulara dinamik de\u011ferler g\u00f6ndermek i\u00e7in <code>variables<\/code> se\u00e7ene\u011fini kullanabilirsiniz.<\/p>\n<pre><code class=\"language-javascript\">import React from 'react';\nimport { gql, useQuery } from '@apollo\/client';\n\nconst GET_PRODUCT_BY_ID = gql<code>\n  query GetProductById($productId: ID!) {\n    product(id: $productId) {\n      id\n      name\n      description\n      price\n    }\n  }\n<\/code>;\n\nfunction ProductDetail({ productId }) {\n  const { loading, error, data } = useQuery(GET_PRODUCT_BY_ID, {\n    variables: { productId }, \/\/ productId de\u011fi\u015fkenini g\u00f6nderiyoruz\n  });\n\n  if (loading) return <p>\u00dcr\u00fcn detay\u0131 y\u00fckleniyor...<\/p>;\n  if (error) return <p>Hata olu\u015ftu: {error.message}<\/p>;\n  if (!data.product) return <p>\u00dcr\u00fcn bulunamad\u0131.<\/p>;\n\n  const { product } = data;\n\n  return (\n    <div>\n      <h2>{product.name}<\/h2>\n      <p>{product.description}<\/p>\n      <p>Fiyat: {product.price} TL<\/p>\n    <\/div>\n  );\n}\n\nexport default ProductDetail;<\/code><\/pre>\n<p>Burada, <code>productId<\/code> prop&#8217;u <code>variables<\/code> nesnesi arac\u0131l\u0131\u011f\u0131yla GraphQL sorgusuna iletilir.<\/p>\n<h3>fetchPolicy ve \u00d6nbellekleme Stratejileri<\/h3>\n<p>Apollo Client, g\u00fc\u00e7l\u00fc bir \u00f6nbelle\u011fe alma mekanizmas\u0131na sahiptir. <code>useQuery<\/code> Hook&#8217;una <code>fetchPolicy<\/code> se\u00e7ene\u011fini ileterek bu \u00f6nbelle\u011fin nas\u0131l kullan\u0131laca\u011f\u0131n\u0131 kontrol edebilirsiniz:<\/p>\n<p>*   <code>cache-first<\/code> (varsay\u0131lan): \u00d6nce \u00f6nbelle\u011fe bakar. Veri varsa onu d\u00f6nd\u00fcr\u00fcr. Yoksa a\u011f\u0131 kullan\u0131r ve sonucu \u00f6nbelle\u011fe al\u0131r.<br \/>\n*   <code>network-only<\/code>: \u00d6nbelle\u011fi tamamen atlar ve her zaman a\u011fdan veri \u00e7eker.<br \/>\n*   <code>cache-and-network<\/code>: \u00d6nce \u00f6nbellekten veriyi d\u00f6nd\u00fcr\u00fcr, ard\u0131ndan a\u011f\u0131 kullanarak g\u00fcncel veriyi \u00e7eker ve \u00f6nbelle\u011fi g\u00fcnceller.<br \/>\n*   <code>no-cache<\/code>: \u00d6nbelle\u011fi kullanmaz ve a\u011fdan gelen veriyi \u00f6nbelle\u011fe almaz.<br \/>\n*   <code>standby<\/code>: Sorguyu \u00e7al\u0131\u015ft\u0131rmaz, ancak di\u011fer sorgular taraf\u0131ndan tetiklenebilir.<\/p>\n<pre><code class=\"language-javascript\">const { loading, error, data } = useQuery(GET_PRODUCTS, {\n  fetchPolicy: 'network-only', \/\/ Her zaman a\u011fdan \u00e7ek\n});<\/code><\/pre>\n<h2>GraphQL Mutasyonlar\u0131 Yapma (useMutation)<\/h2>\n<p><code>useMutation<\/code> Hook&#8217;u, GraphQL API&#8217;nizde veri olu\u015fturmak, g\u00fcncellemek veya silmek i\u00e7in kullan\u0131l\u0131r. <code>useQuery<\/code> gibi, <code>loading<\/code>, <code>error<\/code> durumlar\u0131n\u0131 ve mutasyonu tetikleyecek bir fonksiyonu d\u00f6nd\u00fcr\u00fcr.<\/p>\n<h3>useMutation Hook&#8217;unun Kullan\u0131m\u0131<\/h3>\n<p><code>useMutation<\/code> Hook&#8217;u, bir GraphQL mutasyon dizesi al\u0131r ve bir dizi d\u00f6nd\u00fcr\u00fcr: ilk \u00f6\u011fe mutasyon fonksiyonu, ikinci \u00f6\u011fe ise mutasyonun durumunu i\u00e7eren bir nesnedir.<\/p>\n<pre><code class=\"language-javascript\">import React, { useState } from 'react';\nimport { gql, useMutation } from '@apollo\/client';\n\nconst ADD_PRODUCT = gql<code>\n  mutation AddProduct($name: String!, $description: String, $price: Float!, $categoryId: ID!) {\n    addProduct(name: $name, description: $description, price: $price, categoryId: $categoryId) {\n      id\n      name\n      price\n    }\n  }\n<\/code>;\n\n\/\/ \u00dcr\u00fcn listesini g\u00fcncelleyebilmek i\u00e7in GET_PRODUCTS sorgusunu da alal\u0131m\nimport { GET_PRODUCTS } from '.\/ProductsList'; \/\/ ProductsList bile\u015feninde tan\u0131mlad\u0131\u011f\u0131m\u0131z sorgu\n\nfunction AddProductForm() {\n  const [name, setName] = useState('');\n  const [description, setDescription] = useState('');\n  const [price, setPrice] = useState('');\n  const [categoryId, setCategoryId] = useState('');\n\n  const [addProduct, { loading, error }] = useMutation(ADD_PRODUCT, {\n    \/\/ Mutasyon ba\u015far\u0131l\u0131 oldu\u011funda \u00f6nbelle\u011fi g\u00fcncelleme stratejisi\n    update(cache, { data: { addProduct } }) {\n      \/\/ \u00d6nbellekteki GET_PRODUCTS sorgusunun sonucunu oku\n      const existingProducts = cache.readQuery({ query: GET_PRODUCTS });\n\n      \/\/ Yeni \u00fcr\u00fcn\u00fc mevcut \u00fcr\u00fcn listesine ekle\n      cache.writeQuery({\n        query: GET_PRODUCTS,\n        data: { products: [...existingProducts.products, addProduct] },\n      });\n    },\n    \/\/ Veya daha basit: mutasyon sonras\u0131 belirli sorgular\u0131 yeniden \u00e7ek\n    \/\/ refetchQueries: [{ query: GET_PRODUCTS }],\n  });\n\n  const handleSubmit = async (e) => {\n    e.preventDefault();\n    try {\n      await addProduct({\n        variables: {\n          name,\n          description,\n          price: parseFloat(price),\n          categoryId,\n        },\n      });\n      alert('\u00dcr\u00fcn ba\u015far\u0131yla eklendi!');\n      \/\/ Formu temizle\n      setName('');\n      setDescription('');\n      setPrice('');\n      setCategoryId('');\n    } catch (err) {\n      console.error(\"\u00dcr\u00fcn eklenirken hata olu\u015ftu:\", err);\n    }\n  };\n\n  return (\n    <form onSubmit={handleSubmit}>\n      <h2>Yeni \u00dcr\u00fcn Ekle<\/h2>\n      <div>\n        <label>Ad\u0131:<\/label>\n        <input type=\"text\" value={name} onChange={(e) => setName(e.target.value)} required \/>\n      <\/div>\n      <div>\n        <label>A\u00e7\u0131klama:<\/label>\n        <textarea value={description} onChange={(e) => setDescription(e.target.value)} \/>\n      <\/div>\n      <div>\n        <label>Fiyat:<\/label>\n        <input type=\"number\" step=\"0.01\" value={price} onChange={(e) => setPrice(e.target.value)} required \/>\n      <\/div>\n      <div>\n        <label>Kategori ID:<\/label>\n        <input type=\"text\" value={categoryId} onChange={(e) => setCategoryId(e.target.value)} required \/>\n      <\/div>\n      <button type=\"submit\" disabled={loading}>\n        {loading ? 'Ekleniyor...' : '\u00dcr\u00fcn Ekle'}\n      <\/button>\n      {error && <p style={{ color: 'red' }}>Hata: {error.message}<\/p>}\n    <\/form>\n  );\n}\n\nexport default AddProductForm;<\/code><\/pre>\n<p>Bu \u00f6rnekte:<br \/>\n*   <code>ADD_PRODUCT<\/code> sabiti, <code>gql<\/code> ile bir mutasyon tan\u0131mlar.<br \/>\n*   <code>useMutation(ADD_PRODUCT, ...)<\/code> \u00e7a\u011fr\u0131s\u0131, <code>addProduct<\/code> fonksiyonunu ve mutasyonun durumunu d\u00f6nd\u00fcr\u00fcr.<br \/>\n*   <code>handleSubmit<\/code> fonksiyonu, form g\u00f6nderildi\u011finde <code>addProduct<\/code> fonksiyonunu \u00e7a\u011f\u0131r\u0131r ve <code>variables<\/code> ile gerekli verileri g\u00f6nderir.<br \/>\n*   <code>update<\/code> fonksiyonu, mutasyon ba\u015far\u0131l\u0131 oldu\u011funda Apollo Client&#8217;\u0131n \u00f6nbelle\u011fini manuel olarak g\u00fcncellemek i\u00e7in kullan\u0131l\u0131r. Bu, uygulaman\u0131z\u0131n UI&#8217;\u0131n\u0131, sunucudan tekrar veri \u00e7ekmeye gerek kalmadan g\u00fcncel tutar. <code>refetchQueries<\/code> se\u00e7ene\u011fi ise daha basit bir alternatif sunar: Belirli sorgular\u0131 mutasyon sonras\u0131 otomatik olarak yeniden \u00e7eker.<br \/>\n*   <code>loading<\/code> ve <code>error<\/code> durumlar\u0131, kullan\u0131c\u0131ya geri bildirim sa\u011flamak i\u00e7in kullan\u0131l\u0131r.<\/p>\n<h3>Optimistik UI G\u00fcncellemeleri<\/h3>\n<p>Apollo Client, optimistik UI g\u00fcncellemelerini de destekler. Bu, bir mutasyon g\u00f6nderildi\u011finde, sunucudan yan\u0131t gelmeden \u00f6nce UI&#8217;\u0131n sanki mutasyon ba\u015far\u0131l\u0131 olmu\u015f gibi g\u00fcncellenmesi anlam\u0131na gelir. Kullan\u0131c\u0131 deneyimini iyile\u015ftirir, \u00e7\u00fcnk\u00fc kullan\u0131c\u0131 bir yan\u0131t i\u00e7in beklemek zorunda kalmaz. Mutasyon ba\u015far\u0131s\u0131z olursa, UI otomatik olarak eski durumuna geri d\u00f6ner. Bu, <code>update<\/code> fonksiyonunda <code>optimisticResponse<\/code> se\u00e7ene\u011fi kullan\u0131larak yap\u0131l\u0131r.<\/p>\n<h2>GraphQL Abonelikleri (Subscriptions)<\/h2>\n<p>Abonelikler, ger\u00e7ek zamanl\u0131 uygulamalar olu\u015fturmak i\u00e7in kritik \u00f6neme sahiptir. Apollo Client, <code>useSubscription<\/code> Hook&#8217;u ile GraphQL aboneliklerini kolayca entegre etmenizi sa\u011flar.<\/p>\n<h3>useSubscription Hook&#8217;unun Kullan\u0131m\u0131<\/h3>\n<p>Abonelikler genellikle WebSocket ba\u011flant\u0131lar\u0131 \u00fczerinden \u00e7al\u0131\u015f\u0131r. Apollo Client&#8217;\u0131 abonelikler i\u00e7in yap\u0131land\u0131rmak biraz daha karma\u015f\u0131kt\u0131r, \u00e7\u00fcnk\u00fc bir WebSocket ba\u011flant\u0131s\u0131 i\u00e7in bir <code>ws<\/code> URI&#8217;si ve genellikle bir <code>splitLink<\/code> kullanman\u0131z gerekir.<\/p>\n<pre><code class=\"language-javascript\">\/\/ src\/index.js veya src\/App.js (ApolloClient yap\u0131land\u0131rmas\u0131)\nimport { ApolloClient, InMemoryCache, ApolloProvider, split, HttpLink } from '@apollo\/client';\nimport { GraphQLWsLink } from '@apollo\/client\/link\/subscriptions'; \/\/ Veya '@apollo\/client\/link\/ws'\nimport { getMainDefinition } from '@apollo\/client\/utilities';\n\n\/\/ HTTP ba\u011flant\u0131s\u0131\nconst httpLink = new HttpLink({\n  uri: 'http:\/\/localhost:4000\/graphql'\n});\n\n\/\/ WebSocket ba\u011flant\u0131s\u0131 (abonelikler i\u00e7in)\nconst wsLink = new GraphQLWsLink({\n  url: 'ws:\/\/localhost:4000\/graphql', \/\/ Kendi WebSocket sunucu adresinizle de\u011fi\u015ftirin\n  options: {\n    reconnect: true,\n  },\n});\n\n\/\/ Sorgu t\u00fcr\u00fcne g\u00f6re ba\u011flant\u0131lar\u0131 ay\u0131r\nconst splitLink = split(\n  ({ query }) => {\n    const definition = getMainDefinition(query);\n    return (\n      definition.kind === 'OperationDefinition' &&\n      definition.operation === 'subscription'\n    );\n  },\n  wsLink,\n  httpLink,\n);\n\nconst client = new ApolloClient({\n  link: splitLink, \/\/ Ayr\u0131lm\u0131\u015f ba\u011flant\u0131y\u0131 kullan\n  cache: new InMemoryCache(),\n});\n\n\/\/ ... App bile\u015fenini ApolloProvider ile sarmala<\/code><\/pre>\n<p>Ard\u0131ndan, bir bile\u015fende <code>useSubscription<\/code> kullanabilirsiniz:<\/p>\n<pre><code class=\"language-javascript\">import React from 'react';\nimport { gql, useSubscription } from '@apollo\/client';\n\nconst PRODUCT_ADDED_SUBSCRIPTION = gql<code>\n  subscription OnProductAdded {\n    productAdded {\n      id\n      name\n      price\n    }\n  }\n<\/code>;\n\nfunction NewProductAlert() {\n  const { data, loading, error } = useSubscription(PRODUCT_ADDED_SUBSCRIPTION);\n\n  if (loading) return <p>Yeni \u00fcr\u00fcnler dinleniyor...<\/p>;\n  if (error) return <p>Abonelik hatas\u0131: {error.message}<\/p>;\n\n  if (data) {\n    const { productAdded } = data;\n    return (\n      <div style={{ border: '1px solid green', padding: '10px', margin: '10px 0' }}>\n        <h3>  Yeni \u00dcr\u00fcn Eklendi!<\/h3>\n        <p>ID: {productAdded.id}<\/p>\n        <p>Ad\u0131: {productAdded.name}<\/p>\n        <p>Fiyat: {productAdded.price} TL<\/p>\n      <\/div>\n    );\n  }\n\n  return null;\n}\n\nexport default NewProductAlert;<\/code><\/pre>\n<p>Bu \u00f6rnek, her yeni \u00fcr\u00fcn eklendi\u011finde tetiklenen bir aboneli\u011fi dinler ve bir bildirim g\u00f6sterir.<\/p>\n<h2>Daha \u0130leri Konular ve En \u0130yi Uygulamalar<\/h2>\n<p>GraphQL ve Apollo Client&#8217;\u0131n sundu\u011fu imkanlar olduk\u00e7a geni\u015ftir. \u0130\u015fte baz\u0131 ileri d\u00fczey konular ve en iyi uygulamalar:<\/p>\n<h3>Fragment&#8217;lar<\/h3>\n<p>Fragment&#8217;lar, GraphQL sorgular\u0131nda tekrar eden alan setlerini yeniden kullan\u0131labilir par\u00e7alar halinde tan\u0131mlaman\u0131za olanak tan\u0131r. Bu, sorgular\u0131n\u0131z\u0131n daha d\u00fczenli ve bak\u0131m\u0131 kolay olmas\u0131n\u0131 sa\u011flar.<\/p>\n<pre><code class=\"language-graphql\">fragment ProductFields on Product {\n  id\n  name\n  price\n}\n\nquery GetProductsWithFragments {\n  products {\n    ...ProductFields\n    description\n  }\n}<\/code><\/pre>\n<h3>Hata Y\u00f6netimi<\/h3>\n<p>Apollo Client, a\u011f hatalar\u0131n\u0131, GraphQL hatalar\u0131n\u0131 ve istemci taraf\u0131 hatalar\u0131n\u0131 y\u00f6netmek i\u00e7in g\u00fc\u00e7l\u00fc mekanizmalar sunar. <code>ApolloLink<\/code>&#8216;ler, istek ve yan\u0131t ya\u015fam d\u00f6ng\u00fcs\u00fcne m\u00fcdahale ederek hatalar\u0131 merkezi bir \u015fekilde i\u015flemenize olanak tan\u0131r. \u00d6rne\u011fin, kimlik do\u011frulama hatalar\u0131n\u0131 yakalay\u0131p kullan\u0131c\u0131y\u0131 giri\u015f sayfas\u0131na y\u00f6nlendirebilirsiniz.<\/p>\n<h3>Yerel Durum Y\u00f6netimi<\/h3>\n<p>Apollo Client&#8217;\u0131n <code>InMemoryCache<\/code>&#8216;i, sadece sunucudan gelen verileri de\u011fil, ayn\u0131 zamanda uygulaman\u0131z\u0131n yerel durumunu da y\u00f6netebilir. <code>makeVar<\/code> ve <code>useReactiveVar<\/code> gibi ara\u00e7lar, Redux gibi ayr\u0131 bir durum y\u00f6netimi k\u00fct\u00fcphanesine ihtiya\u00e7 duymadan, uygulaman\u0131z\u0131n yerel durumunu Apollo Client \u00f6nbelle\u011fiyle birlikte y\u00f6netmenizi sa\u011flar.<\/p>\n<pre><code class=\"language-javascript\">import { makeVar } from '@apollo\/client';\n\nexport const cartItemsVar = makeVar([]); \/\/ Bo\u015f bir sepet ile ba\u015fla\n\n\/\/ Bir bile\u015fende:\nimport { useReactiveVar } from '@apollo\/client';\n\nfunction ShoppingCart() {\n  const cartItems = useReactiveVar(cartItemsVar);\n  \/\/ ... sepeti g\u00f6ster\n}<\/code><\/pre>\n<h3>Performans Optimizasyonlar\u0131<\/h3>\n<p>*   <strong>N+1 Problemi:<\/strong> REST API&#8217;lerinde s\u0131k\u00e7a kar\u015f\u0131la\u015f\u0131lan N+1 problemi, GraphQL&#8217;de de uygun \u00e7\u00f6z\u00fcmleyiciler (resolvers) olmadan ortaya \u00e7\u0131kabilir. <code>DataLoader<\/code> gibi k\u00fct\u00fcphaneler, bu t\u00fcr sorunlar\u0131 \u00e7\u00f6zmek i\u00e7in veritaban\u0131 sorgular\u0131n\u0131 toplu hale getirir ve \u00f6nbelle\u011fe al\u0131r.<br \/>\n*   <strong>Sorgu Karma\u015f\u0131kl\u0131\u011f\u0131 S\u0131n\u0131rlamas\u0131:<\/strong> GraphQL sunucunuzda, istemcinin \u00e7ok karma\u015f\u0131k veya derin sorgular g\u00f6ndermesini engelleyerek DDoS sald\u0131r\u0131lar\u0131na kar\u015f\u0131 koruma sa\u011flayabilirsiniz.<\/p>\n<h3>G\u00fcvenlik Hususlar\u0131<\/h3>\n<p>GraphQL API&#8217;nizi g\u00fcvende tutmak i\u00e7in kimlik do\u011frulama (authentication) ve yetkilendirme (authorization) mekanizmalar\u0131n\u0131 do\u011fru bir \u015fekilde uygulaman\u0131z gerekir. Genellikle JWT (JSON Web Token) veya OAuth gibi standart y\u00f6ntemler kullan\u0131l\u0131r. Apollo Client, istek ba\u015fl\u0131klar\u0131na kimlik do\u011frulama token&#8217;lar\u0131n\u0131 eklemek i\u00e7in <code>setContext<\/code> link&#8217;ini kullanman\u0131za olanak tan\u0131r.<\/p>\n<h3>Test Etme<\/h3>\n<p>React Apollo uygulamalar\u0131n\u0131 test etmek i\u00e7in <code>@apollo\/client\/testing<\/code> paketindeki <code>MockedProvider<\/code> bile\u015fenini kullanabilirsiniz. Bu, GraphQL isteklerini taklit etmenize ve bile\u015fenlerinizin farkl\u0131 veri durumlar\u0131na nas\u0131l tepki verdi\u011fini test etmenize olanak tan\u0131r.<\/p>\n<h2>Sonu\u00e7<\/h2>\n<p>GraphQL, modern web uygulamalar\u0131 i\u00e7in g\u00fc\u00e7l\u00fc ve esnek bir veri API&#8217;si sa\u011flama konusunda \u00f6nemli bir ad\u0131md\u0131r. React ile birlikte kullan\u0131ld\u0131\u011f\u0131nda, \u00f6zellikle Apollo Client ekosistemi arac\u0131l\u0131\u011f\u0131yla, geli\u015ftiricilere veri \u00e7ekme, de\u011fi\u015ftirme ve y\u00f6netme konusunda e\u015fsiz bir verimlilik ve kontrol sunar. <code>useQuery<\/code>, <code>useMutation<\/code> ve <code>useSubscription<\/code> gibi Hook&#8217;lar, React bile\u015fenlerinizle GraphQL API&#8217;niz aras\u0131nda sorunsuz bir entegrasyon sa\u011flar.<\/p>\n<p>Bu makalede ele ald\u0131\u011f\u0131m\u0131z temel konular ve ileri d\u00fczey ipu\u00e7lar\u0131, React uygulamalar\u0131n\u0131zda GraphQL&#8217;i ba\u015far\u0131yla kullanmak i\u00e7in sa\u011flam bir ba\u015flang\u0131\u00e7 noktas\u0131 sunmaktad\u0131r. GraphQL&#8217;in tip sistemi, sorgular\u0131n ve mutasyonlar\u0131n net yap\u0131s\u0131, Apollo Client&#8217;\u0131n \u00f6nbellekleme ve durum y\u00f6netimi yetenekleri, uygulaman\u0131z\u0131n daha performansl\u0131, bak\u0131m\u0131 kolay ve \u00f6l\u00e7eklenebilir olmas\u0131n\u0131 sa\u011flar.<\/p>\n<p>GraphQL ve Apollo Client, \u00f6\u011frenme e\u011frisi olan teknolojiler olsa da, sa\u011flad\u0131klar\u0131 faydalar bu \u00e7abaya de\u011ferdir. Daha az kodla daha fazlas\u0131n\u0131 yapman\u0131z\u0131, daha h\u0131zl\u0131 geli\u015ftirmenizi ve daha iyi bir kullan\u0131c\u0131 deneyimi sunman\u0131z\u0131 sa\u011flarlar. Modern React geli\u015ftiricisinin ara\u00e7 setinde GraphQL&#8217;in vazge\u00e7ilmez bir yer edindi\u011fi a\u00e7\u0131kt\u0131r. Bu teknolojileri ke\u015ffetmeye ve yeteneklerinizi geli\u015ftirmeye devam etmenizi \u015fiddetle tavsiye ederiz.<br \/>\n<\/body><\/p>\n","protected":false},"excerpt":{"rendered":"Intro to GraphQL in React Using React Apollo &#038; Apollo Boost\nGiri\u015f\nModern web uygulamalar\u0131, kullan\u0131c\u0131lar\u0131na zengin ve dinamik deneyimler sunmak","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"csco_page_header_type":"","csco_page_load_nextpost":"","csco_page_subscribe_form":"","csco_page_contact_form":"","footnotes":""},"categories":[128],"tags":[],"class_list":{"0":"post-36575","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-react","7":"cs-entry","8":"cs-video-wrap"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.5 (Yoast SEO v25.3.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Intro to GraphQL in React Using React Apollo &amp; Apollo Boost - Kodlar\u0131n Gizemli D\u00fcnyas\u0131<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fatihsoysal.com\/blog\/intro-to-graphql-in-react-using-react-apollo-apollo-boost\/\" \/>\n<meta property=\"og:locale\" content=\"tr_TR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Intro to GraphQL in React Using React Apollo &amp; Apollo Boost\" \/>\n<meta property=\"og:description\" content=\"Intro to GraphQL in React Using React Apollo &amp; Apollo Boost Giri\u015f Modern web uygulamalar\u0131, kullan\u0131c\u0131lar\u0131na zengin ve dinamik deneyimler sunmak\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fatihsoysal.com\/blog\/intro-to-graphql-in-react-using-react-apollo-apollo-boost\/\" \/>\n<meta property=\"og:site_name\" content=\"Kodlar\u0131n Gizemli D\u00fcnyas\u0131\" \/>\n<meta property=\"article:published_time\" content=\"2025-12-20T00:40:43+00:00\" \/>\n<meta name=\"author\" content=\"Fatih Soysal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Yazan:\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fatih Soysal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tahmini okuma s\u00fcresi\" \/>\n\t<meta name=\"twitter:data2\" content=\"17 dakika\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/intro-to-graphql-in-react-using-react-apollo-apollo-boost\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/intro-to-graphql-in-react-using-react-apollo-apollo-boost\/\"},\"author\":{\"name\":\"Fatih Soysal\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"headline\":\"Intro to GraphQL in React Using React Apollo &#038; Apollo Boost\",\"datePublished\":\"2025-12-20T00:40:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/intro-to-graphql-in-react-using-react-apollo-apollo-boost\/\"},\"wordCount\":2524,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"articleSection\":[\"React\"],\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/intro-to-graphql-in-react-using-react-apollo-apollo-boost\/#respond\"]}],\"copyrightYear\":\"2025\",\"copyrightHolder\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/intro-to-graphql-in-react-using-react-apollo-apollo-boost\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/intro-to-graphql-in-react-using-react-apollo-apollo-boost\/\",\"name\":\"Intro to GraphQL in React Using React Apollo & Apollo Boost - Kodlar\u0131n Gizemli D\u00fcnyas\u0131\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\"},\"datePublished\":\"2025-12-20T00:40:43+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/intro-to-graphql-in-react-using-react-apollo-apollo-boost\/#breadcrumb\"},\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/intro-to-graphql-in-react-using-react-apollo-apollo-boost\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/intro-to-graphql-in-react-using-react-apollo-apollo-boost\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Anasayfa\",\"item\":\"https:\/\/fatihsoysal.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Intro to GraphQL in React Using React Apollo &#038; Apollo Boost\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/\",\"name\":\"Fatihsoysal.com\",\"description\":\"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim\",\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"tr\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\",\"name\":\"Fatih Soysal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"tr\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"contentUrl\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"width\":512,\"height\":512,\"caption\":\"Fatih Soysal\"},\"logo\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\"},\"description\":\"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Intro to GraphQL in React Using React Apollo & Apollo Boost - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fatihsoysal.com\/blog\/intro-to-graphql-in-react-using-react-apollo-apollo-boost\/","og_locale":"tr_TR","og_type":"article","og_title":"Intro to GraphQL in React Using React Apollo & Apollo Boost","og_description":"Intro to GraphQL in React Using React Apollo & Apollo Boost Giri\u015f Modern web uygulamalar\u0131, kullan\u0131c\u0131lar\u0131na zengin ve dinamik deneyimler sunmak","og_url":"https:\/\/fatihsoysal.com\/blog\/intro-to-graphql-in-react-using-react-apollo-apollo-boost\/","og_site_name":"Kodlar\u0131n Gizemli D\u00fcnyas\u0131","article_published_time":"2025-12-20T00:40:43+00:00","author":"Fatih Soysal","twitter_card":"summary_large_image","twitter_misc":{"Yazan:":"Fatih Soysal","Tahmini okuma s\u00fcresi":"17 dakika"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fatihsoysal.com\/blog\/intro-to-graphql-in-react-using-react-apollo-apollo-boost\/#article","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/intro-to-graphql-in-react-using-react-apollo-apollo-boost\/"},"author":{"name":"Fatih Soysal","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"headline":"Intro to GraphQL in React Using React Apollo &#038; Apollo Boost","datePublished":"2025-12-20T00:40:43+00:00","mainEntityOfPage":{"@id":"https:\/\/fatihsoysal.com\/blog\/intro-to-graphql-in-react-using-react-apollo-apollo-boost\/"},"wordCount":2524,"commentCount":0,"publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"articleSection":["React"],"inLanguage":"tr","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fatihsoysal.com\/blog\/intro-to-graphql-in-react-using-react-apollo-apollo-boost\/#respond"]}],"copyrightYear":"2025","copyrightHolder":{"@id":"https:\/\/fatihsoysal.com\/blog\/#organization"}},{"@type":"WebPage","@id":"https:\/\/fatihsoysal.com\/blog\/intro-to-graphql-in-react-using-react-apollo-apollo-boost\/","url":"https:\/\/fatihsoysal.com\/blog\/intro-to-graphql-in-react-using-react-apollo-apollo-boost\/","name":"Intro to GraphQL in React Using React Apollo & Apollo Boost - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/#website"},"datePublished":"2025-12-20T00:40:43+00:00","breadcrumb":{"@id":"https:\/\/fatihsoysal.com\/blog\/intro-to-graphql-in-react-using-react-apollo-apollo-boost\/#breadcrumb"},"inLanguage":"tr","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fatihsoysal.com\/blog\/intro-to-graphql-in-react-using-react-apollo-apollo-boost\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/fatihsoysal.com\/blog\/intro-to-graphql-in-react-using-react-apollo-apollo-boost\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Anasayfa","item":"https:\/\/fatihsoysal.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Intro to GraphQL in React Using React Apollo &#038; Apollo Boost"}]},{"@type":"WebSite","@id":"https:\/\/fatihsoysal.com\/blog\/#website","url":"https:\/\/fatihsoysal.com\/blog\/","name":"Fatihsoysal.com","description":"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim","publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"tr"},{"@type":["Person","Organization"],"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1","name":"Fatih Soysal","image":{"@type":"ImageObject","inLanguage":"tr","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","contentUrl":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","width":512,"height":512,"caption":"Fatih Soysal"},"logo":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/"},"description":"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.","url":"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/"}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/36575","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/comments?post=36575"}],"version-history":[{"count":1,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/36575\/revisions"}],"predecessor-version":[{"id":36576,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/36575\/revisions\/36576"}],"wp:attachment":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/media?parent=36575"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/categories?post=36575"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/tags?post=36575"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}