{"id":875,"date":"2026-01-07T11:54:10","date_gmt":"2026-01-07T10:54:10","guid":{"rendered":"https:\/\/mrdataengineer.com\/?p=875"},"modified":"2026-01-07T21:42:44","modified_gmt":"2026-01-07T20:42:44","slug":"a-beginners-guide-to-graphql-part-2","status":"publish","type":"post","link":"https:\/\/mrdataengineer.com\/index.php\/2026\/01\/07\/a-beginners-guide-to-graphql-part-2\/","title":{"rendered":"A Beginner\u2019s Guide to GraphQL- Part 2"},"content":{"rendered":"\n<p>In <a href=\"https:\/\/mrdataengineer.com\/index.php\/2025\/02\/06\/a-beginners-guide-to-graphql-part-1-2\/\">Part 1<\/a>, we explored what GraphQL is and how it\u2019s changing the way developers think about APIs.<br>If you haven\u2019t read it yet, you might want to check it out \u2014 it\u2019ll make what we\u2019re about to cover even clearer.<\/p>\n\n\n\n<p>In this second part, we\u2019re diving into the <strong>heart of GraphQL<\/strong> \u2014 <em>Schemas and Types.<\/em><br>They\u2019re what make GraphQL powerful, flexible, and\u2026 honestly, pretty fun to use.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"what-s-a-graphql-schema-anyway\"><strong>What\u2019s a GraphQL Schema, Anyway?<\/strong><\/h1>\n\n\n\n<p>Think of a <strong>schema<\/strong> as the map of your data world.<br>It describes all the types of data your API can handle \u2014 along with the relationships between them. Everything you can query, mutate, or fetch is defined right here.<\/p>\n\n\n\n<p>Here\u2019s a simple example:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#f6f6f4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>type Book {\n  id: ID!\n  title: String!\n  author: String!\n  publishedYear: Int\n}\n\ntype Query {\n  books: &#91;Book&#93;\n  book(id: ID!): Book\n}\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula-soft\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F286C4\">type<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #97E1F1; font-style: italic\">Book<\/span><span style=\"color: #F6F6F4\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">  id<\/span><span style=\"color: #F286C4\">:<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #97E1F1; font-style: italic\">ID<\/span><span style=\"color: #F286C4\">!<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">  title<\/span><span style=\"color: #F286C4\">:<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #97E1F1; font-style: italic\">String<\/span><span style=\"color: #F286C4\">!<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">  author<\/span><span style=\"color: #F286C4\">:<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #97E1F1; font-style: italic\">String<\/span><span style=\"color: #F286C4\">!<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">  publishedYear<\/span><span style=\"color: #F286C4\">:<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #97E1F1; font-style: italic\">Int<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F286C4\">type<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #97E1F1; font-style: italic\">Query<\/span><span style=\"color: #F6F6F4\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">  books<\/span><span style=\"color: #F286C4\">:<\/span><span style=\"color: #F6F6F4\"> &#91;<\/span><span style=\"color: #97E1F1; font-style: italic\">Book<\/span><span style=\"color: #F6F6F4\">&#93;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">  book(<\/span><span style=\"color: #FFB86C; font-style: italic\">id<\/span><span style=\"color: #F286C4\">:<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #97E1F1; font-style: italic\">ID<\/span><span style=\"color: #F286C4\">!<\/span><span style=\"color: #F6F6F4\">)<\/span><span style=\"color: #F286C4\">:<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #97E1F1; font-style: italic\">Book<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>This tells us a few things:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>There\u2019s a <strong>Book<\/strong> type with fields like <code>id<\/code>, <code>title<\/code>, <code>author<\/code>, and <code>publishedYear<\/code>.<\/li>\n\n\n\n<li>We can <strong>fetch all books<\/strong> with <code>books<\/code> or <strong>get one book<\/strong> by its ID using <code>book<\/code>.<\/li>\n<\/ul>\n\n\n\n<p>Pretty neat, right? You\u2019re basically defining what\u2019s possible in your API.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"the-building-blocks-types\"><strong>The Building Blocks: Types<\/strong><\/h1>\n\n\n\n<p>GraphQL is all about types \u2014 everything revolves around them.<br>They make your API predictable and self-documenting, which means fewer surprises for developers using it.<\/p>\n\n\n\n<p>Here are some basic types you\u2019ll encounter:<\/p>\n\n\n\n<div class=\"wp-block-stackable-columns stk-block-columns stk-block stk-4d1e321\" data-block-id=\"4d1e321\"><style>.stk-4d1e321 {margin-bottom:0px !important;}<\/style><div class=\"stk-row stk-inner-blocks stk-block-content stk-content-align stk-4d1e321-column\">\n<div class=\"wp-block-stackable-column stk-block-column stk-column stk-block stk-c963afd\" data-v=\"4\" data-block-id=\"c963afd\"><style>.stk-c963afd-container{max-width:353px !important;min-width:auto !important;margin-right:auto !important;margin-left:auto !important;}<\/style><div class=\"stk-column-wrapper stk-block-column__content stk-container stk-c963afd-container stk--no-background stk--no-padding\"><div class=\"has-text-align-center stk-block-content stk-inner-blocks stk-c963afd-inner-blocks\"><style>.kb-table-container875_7c185b-5e{overflow-x:auto;}.kb-table-container .kb-table875_7c185b-5e th{padding-top:var(--global-kb-spacing-xxs, 0.5rem);padding-right:var(--global-kb-spacing-xxs, 0.5rem);padding-bottom:var(--global-kb-spacing-xxs, 0.5rem);padding-left:var(--global-kb-spacing-xxs, 0.5rem);text-align:center;}.kb-table-container .kb-table875_7c185b-5e td{padding-top:var(--global-kb-spacing-xxs, 0.5rem);padding-right:var(--global-kb-spacing-xxs, 0.5rem);padding-bottom:var(--global-kb-spacing-xxs, 0.5rem);padding-left:var(--global-kb-spacing-xxs, 0.5rem);text-align:left;}.kb-table-container .kb-table875_7c185b-5e td, .kb-table875_7c185b-5e th{border-top:1px dotted #abb8c3;border-right:1px dotted #abb8c3;border-bottom:1px dotted #abb8c3;border-left:1px dotted #abb8c3;}@media all and (max-width: 1024px){.kb-table-container .kb-table875_7c185b-5e td, .kb-table875_7c185b-5e th{border-top:1px dotted #abb8c3;border-right:1px dotted #abb8c3;border-bottom:1px dotted #abb8c3;border-left:1px dotted #abb8c3;}}@media all and (max-width: 767px){.kb-table-container .kb-table875_7c185b-5e td, .kb-table875_7c185b-5e th{border-top:1px dotted #abb8c3;border-right:1px dotted #abb8c3;border-bottom:1px dotted #abb8c3;border-left:1px dotted #abb8c3;}}<\/style><div class=\"kb-table-container kb-table-container875_7c185b-5e wp-block-kadence-table\"><table class=\"kb-table kb-table875_7c185b-5e\">\n<style>.kb-table-container .kb-table tr.kb-table-row875_b71290-3e{background-color:rgba(171,184,195,0.2);}<\/style><tr class=\"kb-table-row kb-table-row875_b71290-3e\">\n<th class=\"kb-table-data kb-table-data875_dc873a-5c\">\n\n<p><strong>Type<\/strong><\/p>\n\n<\/875_dc873a-5c>\n\n<th class=\"kb-table-data kb-table-data875_2784ce-12\">\n\n<p><strong>What It Means<\/strong><\/p>\n\n<\/875_2784ce-12>\n<\/tr>\n\n<tr class=\"kb-table-row kb-table-row875_9fa02a-11\">\n<td class=\"kb-table-data kb-table-data875_920ff4-be\">\n\n<p><strong>Int<\/strong><\/p>\n\n<\/875_920ff4-be>\n\n<td class=\"kb-table-data kb-table-data875_9bc047-97\">\n\n<p>Whole numbers <\/p>\n\n<\/875_9bc047-97>\n<\/tr>\n\n<tr class=\"kb-table-row kb-table-row875_ae2280-14\">\n<td class=\"kb-table-data kb-table-data875_7c9ab9-33\">\n\n<p><strong>Float<\/strong><\/p>\n\n<\/875_7c9ab9-33>\n\n<td class=\"kb-table-data kb-table-data875_4b5e5e-1d\">\n\n<p>Decimal numbers<\/p>\n\n<\/875_4b5e5e-1d>\n<\/tr>\n\n<tr class=\"kb-table-row kb-table-row875_97ed40-b3\">\n<td class=\"kb-table-data kb-table-data875_c6b59f-11\">\n\n<p><strong>String<\/strong><\/p>\n\n<\/875_c6b59f-11>\n\n<td class=\"kb-table-data kb-table-data875_9d49d7-14\">\n\n<p>Text values<\/p>\n\n<\/875_9d49d7-14>\n<\/tr>\n\n<tr class=\"kb-table-row kb-table-row875_5b2b8d-ff\">\n<td class=\"kb-table-data kb-table-data875_98bda6-13\">\n\n<p><strong>Boolean<\/strong><\/p>\n\n<\/875_98bda6-13>\n\n<td class=\"kb-table-data kb-table-data875_7b8ca9-6c\">\n\n<p>True or false<\/p>\n\n<\/875_7b8ca9-6c>\n<\/tr>\n\n<tr class=\"kb-table-row kb-table-row875_3ed8ad-85\">\n<td class=\"kb-table-data kb-table-data875_a1141b-e7\">\n\n<p><strong>ID<\/strong><\/p>\n\n<\/875_a1141b-e7>\n\n<td class=\"kb-table-data kb-table-data875_40c903-56\">\n\n<p>Unique identifiers for objects<\/p>\n\n<\/875_40c903-56>\n<\/tr>\n<\/table><\/div><\/div><\/div><\/div>\n<\/div><\/div>\n\n\n\n<p>Of course, you can also create your own custom types, like <code>User<\/code>, <code>Product<\/code>, or <code>Book<\/code>, depending on your data.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"reading-and-writing-data\"><strong>Reading and Writing Data<\/strong><\/h1>\n\n\n\n<p>Now that you\u2019ve got a schema and some types, how do you <em>use<\/em> them?<br>That\u2019s where <strong>queries<\/strong> and <strong>mutations<\/strong> come in.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"queries-reading-data\"><strong>Queries = Reading Data<\/strong><\/h3>\n\n\n\n<p>Queries are like asking your API for information.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#f6f6f4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>query {\n  books {\n    title\n    author\n  }\n}\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula-soft\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F286C4\">query<\/span><span style=\"color: #F6F6F4\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">  <\/span><span style=\"color: #E7EE98\">books<\/span><span style=\"color: #F6F6F4\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">    <\/span><span style=\"color: #E7EE98\">title<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">    <\/span><span style=\"color: #E7EE98\">author<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">  }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>And here\u2019s what you might get back:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#f6f6f4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>{\n  \"data\": {\n    \"books\": &#91;\n      { \"title\": \"1984\", \"author\": \"George Orwell\" },\n      { \"title\": \"The Hobbit\", \"author\": \"J.R.R. Tolkien\" }\n    &#93;\n  }\n}\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula-soft\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F6F6F4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">  <\/span><span style=\"color: #97E2F2\">&quot;<\/span><span style=\"color: #97E1F1\">data<\/span><span style=\"color: #97E2F2\">&quot;<\/span><span style=\"color: #F286C4\">:<\/span><span style=\"color: #F6F6F4\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">    <\/span><span style=\"color: #97E2F2\">&quot;<\/span><span style=\"color: #97E1F1\">books<\/span><span style=\"color: #97E2F2\">&quot;<\/span><span style=\"color: #F286C4\">:<\/span><span style=\"color: #F6F6F4\"> &#91;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">      { <\/span><span style=\"color: #97E2F2\">&quot;<\/span><span style=\"color: #97E1F1\">title<\/span><span style=\"color: #97E2F2\">&quot;<\/span><span style=\"color: #F286C4\">:<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #E7EE98\">1984<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #97E2F2\">&quot;<\/span><span style=\"color: #97E1F1\">author<\/span><span style=\"color: #97E2F2\">&quot;<\/span><span style=\"color: #F286C4\">:<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #E7EE98\">George Orwell<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #F6F6F4\"> },<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">      { <\/span><span style=\"color: #97E2F2\">&quot;<\/span><span style=\"color: #97E1F1\">title<\/span><span style=\"color: #97E2F2\">&quot;<\/span><span style=\"color: #F286C4\">:<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #E7EE98\">The Hobbit<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #97E2F2\">&quot;<\/span><span style=\"color: #97E1F1\">author<\/span><span style=\"color: #97E2F2\">&quot;<\/span><span style=\"color: #F286C4\">:<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #E7EE98\">J.R.R. Tolkien<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #F6F6F4\"> }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">    &#93;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">  }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Just what you asked for \u2014 no more, no less.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"mutations-changing-data\"><strong>Mutations = Changing Data<\/strong><\/h3>\n\n\n\n<p>Mutations let you add, update, or delete data.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#f6f6f4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>mutation {\n  addBook(title: \"Dune\", author: \"Frank Herbert\", publishedYear: 1965) {\n    id\n    title\n  }\n}\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula-soft\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F286C4\">mutation<\/span><span style=\"color: #F6F6F4\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">  <\/span><span style=\"color: #E7EE98\">addBook<\/span><span style=\"color: #F6F6F4\">(<\/span><span style=\"color: #FFB86C; font-style: italic\">title<\/span><span style=\"color: #F286C4\">:<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #E7EE98\">Dune<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #FFB86C; font-style: italic\">author<\/span><span style=\"color: #F286C4\">:<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #E7EE98\">Frank Herbert<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #FFB86C; font-style: italic\">publishedYear<\/span><span style=\"color: #F286C4\">:<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #BF9EEE\">1965<\/span><span style=\"color: #F6F6F4\">) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">    <\/span><span style=\"color: #E7EE98\">id<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">    <\/span><span style=\"color: #E7EE98\">title<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">  }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>This would create a new book entry and return its ID and title.<br>One call \u2014 one clean response.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"resolvers-the-hidden-workers\"><strong>Resolvers: The Hidden Workers<\/strong><\/h1>\n\n\n\n<p>Behind every query or mutation, there\u2019s a <strong>resolver<\/strong> \u2014 a function that actually fetches the data.<br>Think of it as the bridge between your GraphQL schema and your database or API.<\/p>\n\n\n\n<p>Here\u2019s a quick Python example:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#f6f6f4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>def resolve_books(root, info):\n    # Fetch all books from the database\n    return db.get_all_books()\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula-soft\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F286C4\">def<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #62E884\">resolve_books<\/span><span style=\"color: #F6F6F4\">(<\/span><span style=\"color: #FFB86C; font-style: italic\">root<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #FFB86C; font-style: italic\">info<\/span><span style=\"color: #F6F6F4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">    <\/span><span style=\"color: #7B7F8B\"># Fetch all books from the database<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">    <\/span><span style=\"color: #F286C4\">return<\/span><span style=\"color: #F6F6F4\"> db.get_all_books()<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>So when you run that <code>books<\/code> query, this resolver goes off and grabs the real data for you.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"why-schemas-and-types-matter\"><strong>Why Schemas and Types Matter<\/strong><\/h1>\n\n\n\n<p>Schemas aren\u2019t just technical details \u2014 they\u2019re what make GraphQL so easy to work with.<br>They ensure:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Predictability<\/strong>: You always know what data is available and how to get it.<\/li>\n\n\n\n<li><strong>Self-documentation<\/strong>: Tools like Apollo Studio or GraphiQL can automatically visualize your schema.<\/li>\n\n\n\n<li><strong>Flexibility<\/strong>: You can evolve your API without breaking old queries.<\/li>\n<\/ul>\n\n\n\n<p>In other words, the schema is your API\u2019s single source of truth.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"up-next\"><strong>Up Next<\/strong><\/h1>\n\n\n\n<p>Now that you know how schemas and types work, you\u2019re ready to start building real queries and mutations.<br>In <strong>Part 3<\/strong>, we\u2019ll dig deeper into <strong>writing and executing queries<\/strong>, <strong>handling arguments<\/strong>, and <strong>connecting to real databases<\/strong>.<\/p>\n\n\n\n<p>Stick around \u2014 this is where GraphQL really starts to shine!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Part 1, we explored what GraphQL is and how it\u2019s changing the way developers think about APIs.If you haven\u2019t read it yet, you might&#8230;<\/p>\n","protected":false},"author":1,"featured_media":9,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_editorskit_title_hidden":false,"_editorskit_reading_time":0,"_editorskit_is_block_options_detached":false,"_editorskit_block_options_position":"{}","_eb_attr":"","_gspb_post_css":"","footnotes":""},"categories":[2,3],"tags":[22,21,23],"class_list":["post-875","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-graphql","category-python","tag-graphql","tag-python","tag-strawberry-graphql"],"_links":{"self":[{"href":"https:\/\/mrdataengineer.com\/index.php\/wp-json\/wp\/v2\/posts\/875","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mrdataengineer.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mrdataengineer.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mrdataengineer.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mrdataengineer.com\/index.php\/wp-json\/wp\/v2\/comments?post=875"}],"version-history":[{"count":17,"href":"https:\/\/mrdataengineer.com\/index.php\/wp-json\/wp\/v2\/posts\/875\/revisions"}],"predecessor-version":[{"id":922,"href":"https:\/\/mrdataengineer.com\/index.php\/wp-json\/wp\/v2\/posts\/875\/revisions\/922"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mrdataengineer.com\/index.php\/wp-json\/wp\/v2\/media\/9"}],"wp:attachment":[{"href":"https:\/\/mrdataengineer.com\/index.php\/wp-json\/wp\/v2\/media?parent=875"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mrdataengineer.com\/index.php\/wp-json\/wp\/v2\/categories?post=875"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mrdataengineer.com\/index.php\/wp-json\/wp\/v2\/tags?post=875"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}