{"id":20826,"date":"2018-02-09T12:15:08","date_gmt":"2018-02-09T10:15:08","guid":{"rendered":"https:\/\/www.webcodegeeks.com\/?p=20826"},"modified":"2018-02-09T10:22:20","modified_gmt":"2018-02-09T08:22:20","slug":"graphql-api-gateway-microservices","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/","title":{"rendered":"GraphQL as an API Gateway to Microservices"},"content":{"rendered":"<p><a href=\"http:\/\/graphql.org\/\">GraphQL<\/a> was released to the public back in 2015, and like an animal raised in captivity, its first steps out in the wild were timid and went largely unnoticed. By now, however, it has garnered some major buzz, and with good reason: it solves some of the trickiest problems that are inherent in standard REST API architecture.<\/p>\n<p>Specifically, GraphQL allows you to evolve your API naturally without versioning, it provides workable documentation, it avoids the problems of over- and under-fetching, and it offers a convenient way to aggregate data from multiple sources with a single request. You can start to appreciate its power and flexibility once you get past its unconventional approach and its deceptive \u201clooks-like-JSON\u201d syntax (this coming from the same people who brought us React and its \u201clooks-like-HTML\u201d syntax).<\/p>\n<p>How can GraphQL be leveraged in an API gateway? It seems like it might be a perfect solution for interacting with multiple microservices, each dedicated to a single resource type. Well, the good news is that you <em>can<\/em> use GraphQL in your API Gateway, and it can live alongside standard REST routes. So in some cases, you can have your cake and eat it too.<\/p>\n<h2>GraphQL in a Nutshell<\/h2>\n<p>Before we get into the gateway code, let\u2019s review the landscape of GraphQL a bit. Unlike REST applications, GraphQL implementations rely on a single endpoint. All GraphQL requests post data (<em>always<\/em> post, never get) to that one endpoint with the query that describes which resources and fields are being requested.<\/p>\n<p>GraphQL distinguishes between read operations as \u201cqueries\u201d and write operations as \u201cmutations.\u201d To support queries, your GraphQL implementation will define a root query object that enumerates all the resource types available for querying (along with their fields and data types). You can think of this as something like a database schema that defines tables and columns.<\/p>\n<p>To support mutations, your GraphQL implementation will define a root mutation object that enumerates all the available mutations and their properties. The mutations can be thought of as actions, <em>eg<\/em>, <code>createUser<\/code> or <code>updateOrder<\/code>. Even within a single language or framework, there is no standard structure for where these GraphQL components should exist, but these critical elements must exist somewhere in any GraphQL implementation.<\/p>\n<h2>Using Both GraphQL and REST Endpoints<\/h2>\n<p>Just because our API gateway has a GraphQL endpoint defined doesn\u2019t mean we can\u2019t have other endpoints too! It is entirely possible to define traditional REST routes in the same application.<\/p>\n<p>Since we want to avoid duplicating code in the gateway, especially the code that makes requests out to the microservices, we have to choose which of our methodologies will be in charge. We could either dissect a GraphQL query and translate it into its corresponding REST requests, or we could translate a REST request into its GraphQL equivalent.<\/p>\n<p>It turns out that the latter is simpler, so that\u2019s the trick we are proposing: translate requests made to REST routes into GraphQL. No code that interacts with the microservices needs to be duplicated because the REST routes simply act as a translation layer for GraphQL.<\/p>\n<h2>In Code<\/h2>\n<p>Now that we have described our plan of attack, let\u2019s look at some code! The <a href=\"https:\/\/github.com\/fireproofsocks\/graphql-example\">repository<\/a> that demonstrates these examples is available on <a href=\"https:\/\/github.com\/fireproofsocks\/graphql-example\">Github<\/a><\/p>\n<p>This is a Node.js application using the popular <a href=\"http:\/\/expressjs.com\/\">Express<\/a> framework. You should be able to clone and install the application following the instructions in the README.<\/p>\n<p>Running <code>yarn run start<\/code> from the command line should fire up the application and start listening on port 4000. Point your browser to <code>http:\/\/localhost:4000\/graphql<\/code> to have a look at the GraphQL endpoint. The righthand side will show you any registered resource types and their fields, so right away you can see how GraphQL offers some workable documentation.<\/p>\n<p>We can run an example query to look up a single user by their ID:<\/p>\n<pre class=\"brush:php\">{\r\n  users(_id: 3){\r\n    name\r\n  }\r\n}\r\n```\r\n\r\nThe result should be:\r\n```\r\n{\r\n  \"data\": {\r\n    \"users\": [\r\n      {\r\n        \"name\": \"Tammy\"\r\n      }\r\n    ]\r\n  }\r\n}<\/pre>\n<p>The code that handles this is inside <code>src\/users.js<\/code>, and it revolves around the <code>GraphQLObjectType<\/code> object. That\u2019s what gives the response its structure and provides workable documentation.<\/p>\n<h2>REST Equivalent<\/h2>\n<p>Next, let\u2019s look at how we might support a REST endpoint that fetches this same data. A conventional route to look up a single user record would follow the pattern of <code>\/users\/:userId<\/code>. Take a look inside the <code>index.js<\/code> and see how it registered the route:<\/p>\n<pre class=\"brush:php\">const users = require('.\/src\/rest\/user');\r\n\/\/ ... \r\napp.use('\/users', users);<\/pre>\n<p>That\u2019s pretty standard Express routing stuff. Let\u2019s take a look at the <code>src\/rest\/user.js<\/code> file to see how it converts the request into GraphQL.<\/p>\n<pre class=\"brush:php\">const app = require('express');\r\nconst router = app.Router();\r\nimport rootSchema from '..\/app';\r\n\r\nimport {graphql} from 'graphql'\r\n\r\nconst query = (q, vars) =&gt; {\r\n    return graphql(rootSchema, q, null, null, vars)\r\n}\r\n\r\n\/\/ Transform response to JSON API format \r\n\/\/ (if desired)\r\nconst transform = (result) =&gt; {\r\n    const user = result.data.users[0];\r\n\r\n    return {\r\n        data: {\r\n            type: 'user',\r\n            id: user._id,\r\n            attributes: {\r\n                name: user.name\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n\r\n\/\/ REST request to get a user\r\nrouter.get('\/:userId', (req, res) =&gt; {\r\n    \/\/ Convert the request into a GraphQL query string\r\n    query(\"query{users(_id:\" + req.params.userId + \"){_id, name}}\")\r\n        .then(result =&gt; {\r\n            const transformed = transform(result)\r\n            res.send(transformed)\r\n        })\r\n        .catch(err =&gt; {\r\n            res.sendStatus(500)\r\n        })\r\n})\r\n\r\nmodule.exports = router;<\/pre>\n<p>This is really where the magic happens. The registered callback for the route assembles the query string and passes it to GraphQL:<\/p>\n<pre class=\"brush:php\">query(\"query{users(_id:\" + req.params.userId + \"){_id, name}}\")<\/pre>\n<p>The query string maps out a query object in that \u201cJSON-like\u201d syntax \u2014 yes, it seems redundant, but there is a root query node there that wraps the part of the query that we used on the interactive GraphQL page.<\/p>\n<p>This approach may remind you of the old days before ORMs where you had to assemble query strings by hand. It may be more appropriate to filter the request parameter before putting it into a query string, but since it gets interpreted by GraphQL, it\u2019s probably safe \u2014 GraphQL will simply choke if the string is not valid.<\/p>\n<p>Included in this output is a transformer function that alters the default GraphQL response into <a href=\"http:\/\/jsonapi.org\/\">JSON API<\/a> format, but that may or may not be something you wish to keep.<\/p>\n<p>You should be able to see this REST endpoint in action by requesting URLs like <a href=\"http:\/\/localhost:4000\/users\/2\">http:\/\/localhost:4000\/users\/2<\/a> and getting responses like:<\/p>\n<pre class=\"brush:php\">{\r\n    \"data\": {\r\n        \"type\": \"user\",\r\n        \"id\": \"2\",\r\n        \"attributes\": {\r\n            \"name\": \"Jo\u00e3o\"\r\n        }\r\n    }\r\n}<\/pre>\n<h2>Requesting a Microservice<\/h2>\n<p>A more complex example involves actually hitting a microservice with a web request. This has been done by requesting an inspirational quote of the day from <a href=\"http:\/\/quotes.rest\/qod.json?category=inspire\">http:\/\/quotes.rest\/qod.json?category=inspire<\/a>.<\/p>\n<p>In order to add GraphQL support for this data, we need to do three things:<\/p>\n<ol>\n<li>Modify the root query object in <code>src\/app.js<\/code>.<\/li>\n<li>Define the Quote resource type in <code>src\/quote.js<\/code>.<\/li>\n<li>Define a service that will fetch the quote data from a remote API in <code>src\/services\/quote.js<\/code>.<\/li>\n<\/ol>\n<h3>Modify the root query<\/h3>\n<p>First we need to add the resource type to the GraphQL root query object inside <code>src\/app.js<\/code>:<\/p>\n<pre class=\"brush:php\">\/\/ src\/app.js\r\nimport {\r\n    GraphQLObjectType,\r\n    GraphQLSchema,\r\n} from 'graphql\/type';\r\n\r\nimport userQuery from '.\/users';\r\nimport agendaQuery from '.\/agenda-interface';\r\nimport quoteQuery from '.\/quote';\r\n\r\nconst query = new GraphQLObjectType({\r\n    name: 'RootQueryType',\r\n    fields: {\r\n        users: userQuery,\r\n        agenda: agendaQuery,\r\n        quote: quoteQuery\r\n    },\r\n});\r\n\r\nexport default new GraphQLSchema({\r\n    query,\r\n});<\/pre>\n<h3>Define the query type<\/h3>\n<p>The quote query object is defined in <code>src\/quote.js<\/code> \u2014 this is almost exactly the same structure as the one used for the user query, but it references a service class whose job it will be to interact with the remote microservice.<\/p>\n<pre class=\"brush:php\">\/\/ src\/quote.js\r\nimport {\r\n    GraphQLObjectType,\r\n    GraphQLNonNull,\r\n    GraphQLString\r\n} from 'graphql\/type';\r\n\r\nimport { getQuote } from '.\/services\/quote'\r\n\r\nexport const QuoteType = new GraphQLObjectType({\r\n    name: 'Quote',\r\n    description: 'Quote of the day from API service',\r\n    fields: () =&gt; ({\r\n        id: {\r\n            type: GraphQLString,\r\n            description: 'Quote id',\r\n        },\r\n        quote: {\r\n            type: new GraphQLNonNull(GraphQLString),\r\n            description: 'The text of the quote',\r\n        },\r\n        author: {\r\n            type: GraphQLString,\r\n            description: 'The person to whom the quote is attributed',\r\n        },\r\n        date: {\r\n            type: GraphQLString,\r\n            description: 'Date in YYYY-MM-DD format',\r\n        }\r\n    })\r\n});\r\n\r\nexport default {\r\n    type: QuoteType,\r\n    resolve: getQuote\r\n}<\/pre>\n<p>This all depends on the <code>getQuote()<\/code> function, which we\u2019ll discuss next.<\/p>\n<h3>Define a service for retrieving remote data<\/h3>\n<p>The <code>getQuote()<\/code> function is defined inside <code>src\/services\/quote.js<\/code>:<\/p>\n<pre class=\"brush:php\">\/\/ src\/services\/quote.js\r\n\/**\r\n * This is where the app calls the microservice responsible for the \"Quote\" resource type.\r\n *\/\r\nimport fetch from 'universal-fetch'\r\n\r\nexport const\r\n    getQuote = () =&gt; {\r\n        const url = 'http:\/\/quotes.rest\/qod.json?category=inspire'\r\n        return fetch(url)\r\n            .then(response =&gt; {\r\n                return response.json()\r\n            })\r\n            .then(json =&gt; {\r\n                return transform(json)\r\n            })\r\n            .catch(err =&gt; {\r\n                console.trace(err)\r\n            })\r\n    }\r\n\r\n\/\/ Transform the raw microservice output into \r\n\/\/ fields\/types defined by the GraphQL type\r\nconst transform = (json) =&gt; {\r\n    const\r\n        { contents } = json,\r\n        { quotes } = contents,\r\n        quote = quotes[0]\r\n\r\n    return {\r\n        id: quote.id,\r\n        quote: quote.quote,\r\n        author: quote.author,\r\n        date: quote.date\r\n    }\r\n}<\/pre>\n<p>The <code>transform<\/code> method here converts whatever format is used by the microservice into the format defined by GraphQL for this resource type. If you need to add fields to your response, you\u2019ll have to add them to your <code>QuoteType<\/code> object in <code>src\/quote.js<\/code>.<\/p>\n<p>Once these parts are complete, you should be able to make queries using GraphQL:<\/p>\n<pre class=\"brush:php\">{\r\n  quote{\r\n    quote,\r\n    author\r\n  }\r\n}<\/pre>\n<h3>Add REST support<\/h3>\n<p>As before, a route is registered inside the <code>index.js<\/code> file:<\/p>\n<pre class=\"brush:php\">const quotes = require('.\/src\/rest\/quote');\r\n\/\/ ...\r\napp.use('\/quote', quotes);<\/pre>\n<p>The REST request acts as a translator to the GraphQL syntax.<\/p>\n<pre class=\"brush:php\">\/\/ src\/rest\/quote.js\r\nconst app = require('express');\r\nconst router = app.Router();\r\nimport rootSchema from '..\/app';\r\nimport {graphql} from 'graphql'\r\n\r\nconst query = (q, vars) =&gt; {\r\n    return graphql(rootSchema, q, null, null, vars)\r\n}\r\n\r\n\/\/ Transform response to JSON API format \r\nconst transform = (result) =&gt; {\r\n    const quote = result.data.quote;\r\n\r\n    return {\r\n        data: {\r\n            type: 'quote',\r\n            id: quote.id,\r\n            attributes: {\r\n                quote: quote.quote,\r\n                author: quote.author,\r\n                date: quote.date\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n\/\/ REST request to get a quote\r\nrouter.get('\/', (req, res) =&gt; {\r\n    \/\/ Convert the request into a GraphQL query string\r\n    query(\"query{quote{id, quote, author, date}}\")\r\n        .then(result =&gt; {\r\n            const transformed = transform(result)\r\n            res.send(transformed)\r\n        })\r\n        .catch(err =&gt; {\r\n            res.sendStatus(500)\r\n        })\r\n})\r\n\r\nmodule.exports = router;<\/pre>\n<p>When complete, the REST endpoint is available at <a href=\"http:\/\/localhost:4000\/quote\">http:\/\/localhost:4000\/quote<\/a>.<\/p>\n<blockquote><p>Note that the quote service has a limit of 10 requests per hour, so it the demonstration can only be used in moderation.<\/p><\/blockquote>\n<h2>Pros<\/h2>\n<p>Now that you\u2019ve seen how you can have your API Gateway be both a GraphQL implementation and support standard REST routes, the benefits should be clear:<\/p>\n<ul>\n<li>You can have your API cake and eat it too. GraphQL or REST? Both!<\/li>\n<li>You can leverage GraphQL\u2019s built-in strengths of aggregating data from multiple services.<\/li>\n<\/ul>\n<h2>Cons<\/h2>\n<p>Most of the disadvantages to this approach have to do with GraphQL in general. The biggest problem with GraphQL when it comes to filling the role of an API gateway is the fact that it operates on a <em>single<\/em> endpoint.<\/p>\n<p>API gateways often define authorization rules, throttling rates, and caching times differently <em>for each route<\/em>. But since GraphQL uses only one endpoint, it\u2019s nearly impossible to define route-specific rules for anything. Consequently, you may need to write authorization, throttling, and caching logic in a separate layer or perhaps even in your microservices themselves.<\/p>\n<p>This can create its own mess of smelly code because the solutions will end up undercutting some of the most basic functionality that we expect from the gateway.<\/p>\n<p>If your API is not publicly consumed, then you are not fielding an infinite number of query variations, so having a GraphQL interpreter that allows a client to ask for any possible resource and field combination is arguably overkill. Supporting a handful of use cases with known response attributes has worked quite well for a lot of setups for a long time, so there may be no need to reinvent that particular wheel.<\/p>\n<p>Another disadvantage with trying to use both GraphQL and REST lies with the documentation: there is no guarantee that your REST endpoints have any documentation, let alone docs that stay in sync with the GraphQL query objects, so you are probably inviting some inconsistencies and busywork if you choose to support both GraphQL and REST in your API gateway.<\/p>\n<h2>Summary<\/h2>\n<p>The solution I have presented here may be an interesting distraction for some, or it may be a viable solution depending on your needs. Although it is possible to have a GraphQL and REST APIs coexist in a single application, the more difficult question is whether or not such a combination is practical.<\/p>\n<p>Like most of the issues surrounding microservices and API gateways, there are no simple right and wrong answers, there are only tradeoffs, and only you can decide which solutions are the best fit for your needs.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>Published on Web Code Geeks with permission by Everett Griffiths, partner at our <a href=\"http:\/\/www.webcodegeeks.com\/join-us\/wcg\/\" target=\"_blank\" rel=\"noopener\">WCG program<\/a>. See the original article here: <a href=\"https:\/\/blog.codeship.com\/graphql-as-an-api-gateway-to-micro-services\/\" target=\"_blank\" rel=\"noopener\">GraphQL as an API Gateway to Microservices<\/a><\/p>\n<p>Opinions expressed by Web Code Geeks contributors are their own.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>GraphQL was released to the public back in 2015, and like an animal raised in captivity, its first steps out in the wild were timid and went largely unnoticed. By now, however, it has garnered some major buzz, and with good reason: it solves some of the trickiest problems that are inherent in standard REST &hellip;<\/p>\n","protected":false},"author":1263,"featured_media":927,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[450,228],"class_list":["post-20826","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-development","tag-graphql","tag-microservices"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>GraphQL as an API Gateway to Microservices - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"GraphQL was released to the public back in 2015, and like an animal raised in captivity, its first steps out in the wild were timid and went largely\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"GraphQL as an API Gateway to Microservices - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"GraphQL was released to the public back in 2015, and like an animal raised in captivity, its first steps out in the wild were timid and went largely\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2018-02-09T10:15:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Everett Griffiths\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Everett Griffiths\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/\"},\"author\":{\"name\":\"Everett Griffiths\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/a6e99417ce902c438505ab20a3215b13\"},\"headline\":\"GraphQL as an API Gateway to Microservices\",\"datePublished\":\"2018-02-09T10:15:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/\"},\"wordCount\":1614,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg\",\"keywords\":[\"GraphQL\",\"Microservices\"],\"articleSection\":[\"Web Dev\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/\",\"name\":\"GraphQL as an API Gateway to Microservices - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg\",\"datePublished\":\"2018-02-09T10:15:08+00:00\",\"description\":\"GraphQL was released to the public back in 2015, and like an animal raised in captivity, its first steps out in the wild were timid and went largely\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Web Dev\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/web-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"GraphQL as an API Gateway to Microservices\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/a6e99417ce902c438505ab20a3215b13\",\"name\":\"Everett Griffiths\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/42ab9793ccc8b6e9c8df2b0977710372de0e1c804be2976441aca90e74d5d0bc?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/42ab9793ccc8b6e9c8df2b0977710372de0e1c804be2976441aca90e74d5d0bc?s=96&d=mm&r=g\",\"caption\":\"Everett Griffiths\"},\"description\":\"Everett Griffiths is a senior software engineer with a passion for writing clean and tested code that scales.\",\"sameAs\":[\"https:\/\/blog.codeship.com\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/fireproofsocks\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"GraphQL as an API Gateway to Microservices - Web Code Geeks - 2026","description":"GraphQL was released to the public back in 2015, and like an animal raised in captivity, its first steps out in the wild were timid and went largely","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:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/","og_locale":"en_US","og_type":"article","og_title":"GraphQL as an API Gateway to Microservices - Web Code Geeks - 2026","og_description":"GraphQL was released to the public back in 2015, and like an animal raised in captivity, its first steps out in the wild were timid and went largely","og_url":"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2018-02-09T10:15:08+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg","type":"image\/jpeg"}],"author":"Everett Griffiths","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Everett Griffiths","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/"},"author":{"name":"Everett Griffiths","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/a6e99417ce902c438505ab20a3215b13"},"headline":"GraphQL as an API Gateway to Microservices","datePublished":"2018-02-09T10:15:08+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/"},"wordCount":1614,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg","keywords":["GraphQL","Microservices"],"articleSection":["Web Dev"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/","url":"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/","name":"GraphQL as an API Gateway to Microservices - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg","datePublished":"2018-02-09T10:15:08+00:00","description":"GraphQL was released to the public back in 2015, and like an animal raised in captivity, its first steps out in the wild were timid and went largely","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/web-development\/graphql-api-gateway-microservices\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Web Dev","item":"https:\/\/www.webcodegeeks.com\/category\/web-development\/"},{"@type":"ListItem","position":3,"name":"GraphQL as an API Gateway to Microservices"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/a6e99417ce902c438505ab20a3215b13","name":"Everett Griffiths","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/42ab9793ccc8b6e9c8df2b0977710372de0e1c804be2976441aca90e74d5d0bc?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/42ab9793ccc8b6e9c8df2b0977710372de0e1c804be2976441aca90e74d5d0bc?s=96&d=mm&r=g","caption":"Everett Griffiths"},"description":"Everett Griffiths is a senior software engineer with a passion for writing clean and tested code that scales.","sameAs":["https:\/\/blog.codeship.com"],"url":"https:\/\/www.webcodegeeks.com\/author\/fireproofsocks\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/20826","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/1263"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=20826"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/20826\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/927"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=20826"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=20826"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=20826"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}