{"id":8219,"date":"2020-02-28T16:03:38","date_gmt":"2020-02-29T00:03:38","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=8219"},"modified":"2025-06-13T21:10:25","modified_gmt":"2025-06-14T04:10:25","slug":"fullstack-react-express-2","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/","title":{"rendered":"Fullstack React and GraphQL : Express Server"},"content":{"rendered":"<p>The second of three articles focused on building Fullstack React and GraphQL with Express and Couchbase Server.<\/p>\n<ul>\n<li><a href=\"https:\/\/www.couchbase.com\/blog\/fullstack-react-couchbase-1\/\">Setting up a NoSQL Couchbase Server (Part 1)<\/a><\/li>\n<li>Building an Express-GraphQL API (Part 2)<\/li>\n<li><a href=\"https:\/\/www.couchbase.com\/blog\/fullstack-react-apollo-3\/\">Create Apollo GraphQL Client in React (Part 3)<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/httpJunkie\/rage-with-couchbase-final\">Final Source Code<\/a><\/li>\n<\/ul>\n<h2 id=\"graphql-with-express\">GraphQL with Express<\/h2>\n<p>If unfamiliar with GraphQL, take a few minutes to get up to speed using the GraphQL documentation. The following pages should be a good start:<\/p>\n<ul>\n<li><a href=\"https:\/\/graphql.org\/learn\/\">Introduction<\/a><\/li>\n<li><a href=\"https:\/\/graphql.org\/learn\/queries\/\">Queries and Mutations<\/a><\/li>\n<li><a href=\"https:\/\/graphql.org\/learn\/schema\/\">Schemas and Types<\/a><\/li>\n<\/ul>\n<h3 id=\"create-project-structure\">Prerequisites<\/h3>\n<ul class=\"p-rich_text_list p-rich_text_list__bullet\" data-stringify-type=\"unordered-list\" data-indent=\"0\">\n<li data-stringify-indent=\"0\"><a class=\"c-link\" href=\"https:\/\/nodejs.org\/\" target=\"_blank\" rel=\"noopener noreferrer\" data-stringify-link=\"https:\/\/nodejs.org\/\" data-sk=\"tooltip_parent\">node<\/a>\u00a0v10.x or later<\/li>\n<li data-stringify-indent=\"0\"><a class=\"c-link\" href=\"https:\/\/www.npmjs.com\/\" target=\"_blank\" rel=\"noopener noreferrer\" data-stringify-link=\"https:\/\/www.npmjs.com\/\" data-sk=\"tooltip_parent\">npm<\/a>\u00a0v5.x or later<\/li>\n<li data-stringify-indent=\"0\"><a class=\"c-link\" href=\"https:\/\/git-scm.com\/\" target=\"_blank\" rel=\"noopener noreferrer\" data-stringify-link=\"https:\/\/git-scm.com\/\" data-sk=\"tooltip_parent\">git<\/a>\u00a0v2.14.1 or later<\/li>\n<\/ul>\n<h3 id=\"create-project-structure\">Create Project Structure<\/h3>\n<p>We need to create a directory on your machine for our project, we will call it <code>rage-with-couchbase<\/code>:<\/p>\n<pre class=\"highlight decode:true\"><code class=\"language-bash\">mkdir rage-with-couchbase &amp;&amp; cd $_<\/code><\/pre>\n<p><code>mkdir<\/code> will create a new directory using the string <code>rage-with-couchbase<\/code> for the folder&#8217;s name, bash stores that string in a variable we can use immediately named <code>$_<\/code>.<\/p>\n<p>we change directories using <code>$_<\/code> ensuring we don&#8217;t misspell the directory on the concatenated command (it&#8217;s bash magic).<\/p>\n<p>Now let&#8217;s create a <code>.gitignore<\/code> file in the root of our project.<\/p>\n<pre class=\"highlight decode:true\"><code>touch .gitignore &amp;&amp; echo \"\/node_modules\/*\" &gt;&gt; .gitignore<\/code><\/pre>\n<p><code>touch<\/code> will generate a <code>.gitignore<\/code> file ignoring all <code>node_modules<\/code> directories and sub-directories in our project. This is important because as part of our fullstack React and GraphQL demo project, we will be tracking git changes from the root <code>rage-with-couchbase<\/code> directory, but we will have server and client directories with their own <code>package.json<\/code> and <code>node_modules<\/code> directory.<\/p>\n<p><code>echo<\/code> will add the <code>node_modules\/<\/code> text inside the <code>.gitignore<\/code> file, this will serve to ignore all <strong>node_modules<\/strong> directories in the root and all subdirectories.<\/p>\n<h3 id=\"creating-our-express-server\">Creating Our Express Server<\/h3>\n<p>Now we will create the directory to store our Express server and we will use npm to manage its packages.<\/p>\n<pre class=\"highlight decode:true\"><code class=\"language-bash\">mkdir couchbase-gql-server &amp;&amp; cd $_ &amp;&amp; npm init -y<\/code><\/pre>\n<p><code>mkdir<\/code> will create a new folder inside the project root specifically for our server using the string <code>couchbase-gql-server<\/code> for the name, this is your server project directory.<\/p>\n<p>we change directories and use the <code>$_<\/code> (more magic) and then we initialize an <strong>npm<\/strong> project using <code>npm init -y<\/code> accepting the default values with the <code>-y<\/code> flag.<\/p>\n<h3 id=\"install-express-server-dependencies\">Install Express Server Dependencies<\/h3>\n<pre class=\"highlight decode:true\"><code class=\"language-bash\">npm install graphql express express-graphql couchbase &amp;&amp; npm install nodemon -D &amp;&amp; code .<\/code><\/pre>\n<p>Once install is finished, we need to open our project with our editor of choice. I prefer VS Code.<\/p>\n<h3 id=\"create-our-graphql-server\">Create Our GraphQL Server<\/h3>\n<pre class=\"highlight decode:true\"><code class=\"language-bash\">touch server.js .gitignore &amp;&amp; echo \"\/node_modules\/*\" &gt;&gt; .gitignore<\/code><\/pre>\n<p>Require <code>express\/express-graphql\/graphql<\/code> in our <code>server.js<\/code> file:<\/p>\n<pre><code class=\"language-JavaScript\">const express = require('express')\r\nconst { graphqlHTTP } = require('express-graphql')\r\nconst { buildSchema } = require('graphql')\r\n    \r\nconst couchbase = require('couchbase')<\/code><\/pre>\n<p>The first three imports are needed for our GraphQL server and the last import is required for connecting to and querying our Couchbase Server.<\/p>\n<h3 id=\"initialize-express-and-connect-to-our-bucket\">Initialize Express and Connect to Our Bucket<\/h3>\n<p>Add the following code:<\/p>\n<pre class=\"highlight decode:true\"><code class=\"language-JavaScript\">const app = express()\r\nconst cluster = new couchbase.Cluster('couchbase:\/\/localhost', { \r\n  username: 'Administrator', password: 'password' \r\n})\r\nconst bucket = cluster.bucket('travel-sample')\r\nvar collection = bucket.defaultCollection();<\/code><\/pre>\n<p>Above we are connecting to our Couchbase Server cluster, authenticating with our user that we set up, and opening our <code>travel-sample<\/code> bucket. Never use default usernames and passwords in production applications.<\/p>\n<h3 id=\"create-our-graphql-schema\">Create Our GraphQL Schema<\/h3>\n<p>Adding the code below will define two endpoints that will enable our GraphQL Server to access and retrieve data from our documents inside of our Couchbase Server bucket.<\/p>\n<pre><code class=\"language-JavaScript\">const schema = buildSchema(`\r\n  type Airline {\r\n    id: Int,\r\n    callsign: String,\r\n    country: String,\r\n    iata: String,\r\n    icao: String,\r\n    name: String,\r\n    type: String\r\n  }\r\n  input AirlineInput {\r\n    callsign: String,\r\n    country: String,\r\n    iata: String,\r\n    icao: String,\r\n    name: String,\r\n    type: String\r\n  }\r\n  type Query {\r\n    airlinesUK: [Airline],\r\n    airlineByKey(id: Int!): Airline\r\n    airlinesByRegion(region: String!): [Airline]\r\n  }\r\n  type Mutation {\r\n    updateAirline(id: Int!, input: AirlineInput): Airline\r\n  }<\/code><\/pre>\n<p>The <code>Query<\/code> type specifies which <a href=\"https:\/\/www.couchbase.com\/blog\/processing-graphql-queries-with-java-spring-boot-and-nosql\/\">GraphQL queries<\/a> clients can execute against its own data graph.<\/p>\n<p>We have two endpoints defined by that <code>Query<\/code>. One named &#8220;airlinesUK&#8221; and the other &#8220;airlineByKey&#8221;. In our React app, we will only use the &#8220;airlinesUK&#8221; endpoint. I made the &#8220;airlineByKey&#8221; endpoint simply to show an example of retrieving a single Couchbase document by key. This operation does not use the N1QL query language and therefore does not have any additional overhead. Understanding when and where to use each is important from the perspective of building the API, we wouldn&#8217;t want to use a N1QL query to return a single document that we can get by key.<\/p>\n<p>In our GraphQL code, we have an object of type <code>Airline<\/code>. This object model the document structure found in our Couchbase `travel-sample` bucket where the type is &#8220;airline&#8221;.<\/p>\n<p>Next, we have an Endpoint named &#8220;<code>airlinesUK<\/code>&#8220;. Notice that the return value of this endpoint is an array of Airline: <code>[Airline]<\/code>. This means we will be getting a list of airlines back.<\/p>\n<p>We also have &#8220;<code>airlineByKey<\/code>&#8221; endpoint where we will fetch a single <code>Airline<\/code>.<\/p>\n<p>If you remember from our Bucket images above, each document is defined by a key in a format like <code>airline_1234<\/code> where <code>1234<\/code> is the <code>id<\/code> of the airline.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2020\/01\/travel-sample-document.jpg\" alt=\"travel-sample document\" \/><\/p>\n<p>We will keep this <code>id<\/code> in mind when using the NodeJS SDK to fetch our individual <code>airlineByKey<\/code> using a simple <code>bucket.get()<\/code> method.<\/p>\n<h3 id=\"create-our-resolver-implementation-for-each-endpoint\">Create Our Resolver Implementation for Each Endpoint<\/h3>\n<p>Now, that we have defined two queries in our GraphQL-Express API using our <code>schema<\/code> object, we need implementation in JavaScript for retrieving the data.<\/p>\n<p>Our React application that we will create will only need the <strong>N1QL<\/strong> query named <code>airlinesUK<\/code>.<\/p>\n<p>But I wanted to show you how to query without <strong>N1QL<\/strong> using the NodeJS SDK&#8217;s API using just a key or extending it to use a region (US\/UK, etc..), that is the <code>airlineByKey<\/code> and <code>airlineByRegion<\/code> implementation.<\/p>\n<p>Add the following code to our <code>server.js<\/code> file for our N1QL queries:<br \/>\n(In your JS code, ensure to escape backticks with backslashes)<\/p>\n<pre class=\"highlight decode:true\"><code class=\"language-JavaScript\">\/\/ Define N1QL Queries\r\nconst airlinesUkQuery = `\r\n  SELECT airline.* \r\n  FROM \\`travel-sample\\` AS airline \r\n  WHERE airline.type = 'airline'\r\n  AND airline.country = 'United Kingdom'\r\n`\r\nconst airlinesByRegionQuery = `\r\n  SELECT airline.* \r\n  FROM \\`travel-sample\\` AS airline \r\n  WHERE airline.type = 'airline'\r\n    AND airline.country = $REGION\r\n`<\/code><\/pre>\n<p>Add the following code to our <code>server.js<\/code> file for our GraphQL resolvers:<\/p>\n<pre class=\"highlight decode:true\"><code class=\"language-JavaScript\">const root = {\r\n  airlinesUK: async () =&gt; {\r\n    const result = await cluster.query(airlinesUkQuery)\r\n    return result.rows\r\n  },\r\n  \/*\r\n    query getAirlinesUK {\r\n      airlinesUK {\r\n        id\r\n        name\r\n        callsign\r\n        country\r\n        iata\r\n        icao\r\n      }\r\n    }\r\n  *\/\r\n  airlinesByRegion: async ({region}) =&gt; {\r\n    const options = { parameters: { REGION: region } }\r\n    const result = await cluster.query(airlinesByRegionQuery, options)\r\n    return result.rows\r\n  },\r\n  \/*\r\n    query getAirlinesByRegion($region: String!) {\r\n      airlinesByRegion(region:$region) {\r\n        id\r\n        name\r\n        callsign\r\n        country\r\n        iata\r\n        icao\r\n      }\r\n    }\r\n    {\r\n      \"region\": \"{{country}}\"\r\n    }\r\n  *\/\r\n  airlineByKey: async ({id}) =&gt; {\r\n    const result = await collection.get(`airline_${id}`)\r\n    return result.value\r\n  },\r\n  \/*\r\n    query getAirlineByKey($id: Int!) {\r\n      airlineByKey(id:$id) {\r\n        id\r\n        name\r\n        callsign\r\n        country\r\n        iata\r\n        icao\r\n      }\r\n    }\r\n    {\r\n      \"id\": {{id}}\r\n    }\r\n  *\/\r\n  updateAirline: async ({id, input}) =&gt; {\r\n    const result = await collection.get(`airline_${id}`)\r\n\r\n    const newDocument = {\r\n      ...result.content, \r\n      callsign: input.callsign ? input.callsign : result.value.callsign,\r\n      country: input.country ? input.country : result.value.country,\r\n      iata: input.iata ? input.iata : result.value.iata,\r\n      icao: input.icao ? input.icao : result.value.icao,\r\n      name: input.name ? input.name : result.value.name,\r\n    };\r\n\r\n    console.log(newDocument)\r\n\r\n    await collection.upsert(`airline_${id}`, newDocument)\r\n    return newDocument\r\n  }\r\n  \/*\r\n    mutation updateExistingAirline($id:Int!, $input:AirlineInput) {\r\n      updateAirline(id:$id, input:$input){\r\n        callsign\r\n        country\r\n        iata\r\n      }\r\n    }\r\n    {\r\n      \"id\": 112,\r\n      \"input\": {\r\n        \"callsign\": \"FLYSTAR\",\r\n        \"country\": \"United Kingdom\"\r\n      }\r\n    }\r\n  *\/\r\n}<\/code><\/pre>\n<p>Note: In the N1QL statement above, you will need to escape the backticks in the FROM line around <code>`travel-sample`<\/code> with backslashes. Our blog&#8217;s code sample does not show those Backslashes, but they are there and they are in the <a href=\"https:\/\/github.com\/httpJunkie\/rage-with-couchbase-final\">Final Source Code<\/a><\/p>\n<p>Just to drive this home, we are using two different methods to query our Couchbase Server.<\/p>\n<p>The first method corresponds to the <code>airlinesUK<\/code> endpoint, this is its resolver. We need to return a promise and inside rely on <code>bucket.query<\/code>to take a predefined N1QL query that I have broken up line by line in the statement variable for readability. Being able to run this type of SQL query is very powerful for a document database. A lot of the SQL we know transfers over and this is a big relief compared to other document databases that have a brand new API and query language you will need to learn.<\/p>\n<p>The second method corresponds to the <code>airlinesUK<\/code> endpoint, this is its resolver. We need to return a promise and inside rely on <code>bucket.get<\/code> method and in this case, we are just defining the key of our document. Remember that one of the great things about using a key-value data store is that we can easily pick out a single document with little overhead.<\/p>\n<p>Each of the methods above also tests for query errors and either resolve or reject based on a <code>result<\/code> or <code>error<\/code>.<\/p>\n<h3 id=\"creating-our-express-graphql-server\">Creating Our GraphQL with Express Server<\/h3>\n<p>Now that we have everything sorted out for our endpoints and queries, all we need to do is <code>use<\/code> our Express server and give it a port to run on, let&#8217;s do that now.<\/p>\n<p>Add the following code to the end of our <code>server.js<\/code> file:<\/p>\n<pre class=\"highlight decode:true\"><code class=\"language-JavaScript\">\/*  \r\n  The graphqlHTTP function accepts a schema, rootValue and graphiql \r\n    among other options for configuring our GraphQL Server \r\n*\/\r\nconst serverPort = 4000\r\nconst serverUrl = '\/graphql'\r\napp.use(serverUrl, graphqlHTTP({\r\n  schema: schema,\r\n  rootValue: root,\r\n  graphiql: true\r\n}))\r\n\r\napp.listen(\r\n  serverPort, \r\n  () =&gt; console.log(`GraphQL server running: https:\/\/localhost:${serverPort}${serverUrl}`)\r\n)<\/code><\/pre>\n<p>If you have ever created an Express or Express-GraphQL server, this code should look familiar.<\/p>\n<p>First, we set up our port and GraphQL URL.<\/p>\n<p>Next, we pass in our GraphQL schema and its resolvers and set our <code>graphiql<\/code> option to true. (This will give us an IDE to test our GraphQL queries available at <a href=\"https:\/\/localhost:4000\/graphql\">localhost:4000\/graphql<\/a>.<\/p>\n<p>Finally, we listen on port 4000 and set a message in the console to indicate our server is running.<\/p>\n<p>Let&#8217;s run our server, ensure that your Couchbase:<\/p>\n<pre class=\"highlight decode:true\"><code class=\"language-bash\">node server<\/code><\/pre>\n<p>Once we have the GraphQL server running we can test the <code>AirlinesUK<\/code> query by pasting the following code into the GraphQL IDE query pane:<\/p>\n<pre><code class=\"language-graphiQL\">query getAirlinesUK{\r\n  airlinesUK {\r\n    id\r\n    name\r\n    callsign\r\n    country\r\n    iata\r\n    icao\r\n  }\r\n}<\/code><\/pre>\n<p>As the query indicates it will retrieve all of our UK based airlines:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2020\/01\/travel-sample-graphiql-airlinesUK.jpg\" alt=\"GraphQL with Express GraphiQL demo all UK airlines\" \/><\/p>\n<p>Next, we will use the <code>airlineByKey<\/code> endpoint, in this example, we will also need to create a query variable and paste it into the respective pane:<\/p>\n<pre><code class=\"language-graphiQL\">query getAirlineByKey($id: Int!) {\r\n  airlineByKey(id:$id){\r\n    id\r\n    name\r\n    callsign\r\n    country\r\n    iata\r\n    icao\r\n  }\r\n}<\/code><\/pre>\n<pre><code class=\"language-graphiQL\">{\r\n  \"id\": 112\r\n}<\/code><\/pre>\n<p>And with that in place and we can query again and retrieve a single airline document by key:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2020\/01\/travel-sample-graphiql-airlineByKey.jpg\" alt=\"GraphQL with Express GraphiQL demo UK airline by key\" \/><\/p>\n<p>With a super simple GraphQL API setup, we are ready to <a href=\"https:\/\/www.couchbase.com\/blog\/fullstack-react-apollo-3\/\">create our react application<\/a> that will use these endpoints for a master-detail page using the UK airlines in a list component and when we click a particular Airline, another component will show the full details of the airline on the right side of the page.<\/p>\n<p><a href=\"https:\/\/www.couchbase.com\/blog\/fullstack-react-apollo-3\/\">Create Apollo GraphQL Client in React (Part 3)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The second of three articles focused on building Fullstack React and GraphQL with Express and Couchbase Server. Setting up a NoSQL Couchbase Server (Part 1) Building an Express-GraphQL API (Part 2) Create Apollo GraphQL Client in React (Part 3) Final [&hellip;]<\/p>\n","protected":false},"author":53002,"featured_media":10873,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1816,1822,1812,2201],"tags":[1254,1669,2210,2454],"ppma_author":[8922],"class_list":["post-8219","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-couchbase-server","category-node-js","category-n1ql-query","category-tools-sdks","tag-express","tag-express-framework","tag-graphql","tag-react"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v25.9) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Fullstack React and GraphQL : Express Server - The Couchbase Blog<\/title>\n<meta name=\"description\" content=\"Build an API server using GraphQL with Express in this three part series on building a fullstack React and GraphQL application.\" \/>\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.couchbase.com\/blog\/fullstack-react-express-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Fullstack React and GraphQL : Express Server\" \/>\n<meta property=\"og:description\" content=\"Build an API server using GraphQL with Express in this three part series on building a fullstack React and GraphQL application.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2020-02-29T00:03:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T04:10:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/02\/express-graphql.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Eric Bishard\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@httpJunkie\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Eric Bishard\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/\"},\"author\":{\"name\":\"Eric Bishard\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/67d3a4b597e42370ccd34b715a6b1f4c\"},\"headline\":\"Fullstack React and GraphQL : Express Server\",\"datePublished\":\"2020-02-29T00:03:38+00:00\",\"dateModified\":\"2025-06-14T04:10:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/\"},\"wordCount\":1284,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/02\/express-graphql.jpg\",\"keywords\":[\"express\",\"express framework\",\"graphql\",\"React\"],\"articleSection\":[\"Couchbase Server\",\"Node.js\",\"SQL++ \/ N1QL Query\",\"Tools &amp; SDKs\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/\",\"name\":\"Fullstack React and GraphQL : Express Server - The Couchbase Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/02\/express-graphql.jpg\",\"datePublished\":\"2020-02-29T00:03:38+00:00\",\"dateModified\":\"2025-06-14T04:10:25+00:00\",\"description\":\"Build an API server using GraphQL with Express in this three part series on building a fullstack React and GraphQL application.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/02\/express-graphql.jpg\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/02\/express-graphql.jpg\",\"width\":1200,\"height\":628,\"caption\":\"RAGE With Couchbase Express-GraphQL\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Fullstack React and GraphQL : Express Server\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/67d3a4b597e42370ccd34b715a6b1f4c\",\"name\":\"Eric Bishard\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/b7d1d2580c41d35a21654fb1abe65d23\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/a316a2658772914defd259571b8cad18878eb23c9d0cc3a97dd803deca0c09ca?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/a316a2658772914defd259571b8cad18878eb23c9d0cc3a97dd803deca0c09ca?s=96&d=mm&r=g\",\"caption\":\"Eric Bishard\"},\"description\":\"International speaker, blogging and advocating for the JavaScript, React, GraphQL and NoSQL community working as a Senior Developer Advocate for Couchbase.\",\"sameAs\":[\"https:\/\/www.reactstateofmind.com\",\"https:\/\/www.linkedin.com\/in\/eric-b\/\",\"https:\/\/x.com\/httpJunkie\"],\"url\":\"https:\/\/www.couchbase.com\/blog\/author\/eric-bishard\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Fullstack React and GraphQL : Express Server - The Couchbase Blog","description":"Build an API server using GraphQL with Express in this three part series on building a fullstack React and GraphQL application.","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.couchbase.com\/blog\/fullstack-react-express-2\/","og_locale":"en_US","og_type":"article","og_title":"Fullstack React and GraphQL : Express Server","og_description":"Build an API server using GraphQL with Express in this three part series on building a fullstack React and GraphQL application.","og_url":"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/","og_site_name":"The Couchbase Blog","article_published_time":"2020-02-29T00:03:38+00:00","article_modified_time":"2025-06-14T04:10:25+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/02\/express-graphql.jpg","type":"image\/jpeg"}],"author":"Eric Bishard","twitter_card":"summary_large_image","twitter_creator":"@httpJunkie","twitter_misc":{"Written by":"Eric Bishard","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/"},"author":{"name":"Eric Bishard","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/67d3a4b597e42370ccd34b715a6b1f4c"},"headline":"Fullstack React and GraphQL : Express Server","datePublished":"2020-02-29T00:03:38+00:00","dateModified":"2025-06-14T04:10:25+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/"},"wordCount":1284,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/02\/express-graphql.jpg","keywords":["express","express framework","graphql","React"],"articleSection":["Couchbase Server","Node.js","SQL++ \/ N1QL Query","Tools &amp; SDKs"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/","url":"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/","name":"Fullstack React and GraphQL : Express Server - The Couchbase Blog","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/02\/express-graphql.jpg","datePublished":"2020-02-29T00:03:38+00:00","dateModified":"2025-06-14T04:10:25+00:00","description":"Build an API server using GraphQL with Express in this three part series on building a fullstack React and GraphQL application.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/02\/express-graphql.jpg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/02\/express-graphql.jpg","width":1200,"height":628,"caption":"RAGE With Couchbase Express-GraphQL"},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/fullstack-react-express-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Fullstack React and GraphQL : Express Server"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"The Couchbase Blog","description":"Couchbase, the NoSQL Database","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/67d3a4b597e42370ccd34b715a6b1f4c","name":"Eric Bishard","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/b7d1d2580c41d35a21654fb1abe65d23","url":"https:\/\/secure.gravatar.com\/avatar\/a316a2658772914defd259571b8cad18878eb23c9d0cc3a97dd803deca0c09ca?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a316a2658772914defd259571b8cad18878eb23c9d0cc3a97dd803deca0c09ca?s=96&d=mm&r=g","caption":"Eric Bishard"},"description":"International speaker, blogging and advocating for the JavaScript, React, GraphQL and NoSQL community working as a Senior Developer Advocate for Couchbase.","sameAs":["https:\/\/www.reactstateofmind.com","https:\/\/www.linkedin.com\/in\/eric-b\/","https:\/\/x.com\/httpJunkie"],"url":"https:\/\/www.couchbase.com\/blog\/author\/eric-bishard\/"}]}},"authors":[{"term_id":8922,"user_id":53002,"is_guest":0,"slug":"eric-bishard","display_name":"Eric Bishard","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/a316a2658772914defd259571b8cad18878eb23c9d0cc3a97dd803deca0c09ca?s=96&d=mm&r=g","author_category":"","last_name":"Bishard","first_name":"Eric","job_title":"","user_url":"https:\/\/www.reactstateofmind.com","description":"International speaker, blogging and advocating for the JavaScript, React, GraphQL and NoSQL community working as a Senior Developer Advocate for Couchbase."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/8219","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/users\/53002"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=8219"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/8219\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/10873"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=8219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=8219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=8219"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=8219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}