{"id":1050,"date":"2022-09-01T06:13:36","date_gmt":"2023-02-20T15:56:49","guid":{"rendered":"https:\/\/www.silicloud.com\/blog\/uncategorized\/one-potential-paraphrase-could-becreating-a-graphql-api-using-prisma-and-launching-it-on-digitaloceans-app-platform\/"},"modified":"2024-03-14T15:28:44","modified_gmt":"2024-03-14T15:28:44","slug":"creating-a-graphql-api-using-prisma-on-silicon-clouds-app-platform","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/blog\/creating-a-graphql-api-using-prisma-on-silicon-clouds-app-platform\/","title":{"rendered":"Creating a GraphQL API using Prisma on Silicon Cloud&#8217;s App Platform"},"content":{"rendered":"<p>As part of the Write for Donations program, the authors opted to donate to the COVID-19 Relief Fund and the Tech Education Fund.<\/p>\n<h3>To begin with,<\/h3>\n<p>GraphQL is an API query language that includes a language for defining the structure of an API, as well as a language for querying data from the API. It allows API users to selectively retrieve only the data they require, providing the flexibility in querying. With GraphQL, developers can adapt the API to cater to various client needs such as iOS, Android, and web versions of an application. Additionally, the GraphQL schema ensures type safety and serves as a form of documentation for the API.<\/p>\n<p>Prisma consists of three primary tools, which are part of an open-source database toolkit.<\/p>\n<ul class=\"post-ul\">\n<li>Prisma Client: Auto-generated and type-safe query builder for <a href=\"https:\/\/nodejs.org\/en\">Node.js<\/a> &amp; TypeScript.<\/li>\n<li>Prisma Migrate: Declarative data modeling &amp; migration system.<\/li>\n<li>Prisma Studio: GUI to view and edit data in your database.<\/li>\n<\/ul>\n<p>Prisma simplifies database operations for developers working on applications, enabling them to concentrate on implementing valuable features instead of dealing with intricate database tasks like schema migrations or writing complex SQL queries.<\/p>\n<p>In this guide, you will learn how to integrate GraphQL and Prisma together as they work effectively in tandem. GraphQL offers a versatile interface for accessing data in various client applications like frontends and mobile apps, without being limited to any particular database. Prisma, on the other hand, takes care of the database interaction and handling the storage of your data.<\/p>\n<p>With Silicon Cloud&#8217;s App Platform, you can easily deploy applications and set up databases in the cloud without the need to concern yourself with infrastructure. This simplifies the process of running applications in the cloud, especially when it comes to creating a managed PostgreSQL database that includes daily backups and automated failover. Moreover, App Platform offers native support for Node.js, making deployment even more efficient.<\/p>\n<p>Using Node.js, you will construct a GraphQL API for a blogging application. Initially, with the help of Apollo Server, you will create the GraphQL API using in-memory data structures. Following that, you will deploy the API on the Silicon Cloud App Platform. Lastly, you will implement Prisma to substitute the in-memory storage, store the data in a PostgreSQL database, and redeploy the application.<\/p>\n<p>By the end of the tutorial, you will successfully deploy a Node.js GraphQL API on Silicon Cloud. This API will effectively manage GraphQL requests transmitted through HTTP and execute CRUD operations on a PostgreSQL database.<\/p>\n<p>The code for this project can be found in the Silicon Cloud Community repository.<\/p>\n<h2>Requirements<\/h2>\n<p>Prior to starting this guide, there are certain items you will require.<\/p>\n<ul class=\"post-ul\">\n<li>A GitHub account.<\/li>\n<li>A Silicon Cloud account.<\/li>\n<li>Git installed on your computer. You can follow the tutorial Contributing to Open Source: Getting Started with Git to install and set up Git on your computer.<\/li>\n<li>Node.js version 14 or higher installed on your computer. You can follow the tutorial How to Install Node.js and Create a Local Development Environment to install and set up Node.js on your computer.<\/li>\n<li>Docker installed on your computer (to run the PostgreSQL database locally).<\/li>\n<\/ul>\n<p>It would be beneficial to have some prior knowledge of JavaScript, Node.js, GraphQL, and PostgreSQL for this tutorial, but it is not absolutely necessary.<\/p>\n<h2>The first step involves the creation of the Node.js project.<\/h2>\n<p>In this phase, you&#8217;ll initialize a Node.js project using npm and incorporate the required apollo-server and graphql dependencies. This project will serve as the basis for the GraphQL API you&#8217;ll develop and deploy in this guide.<\/p>\n<p>To begin with, establish a fresh folder specifically for your project.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">mkdir<\/span> prisma-graphql<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Afterwards, proceed to enter the directory and start a new npm project with no initial content.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token builtin class-name\">cd<\/span> prisma-graphql<\/li>\n<li data-prefix=\"$\"><span class=\"token function\">npm<\/span> init <span class=\"token parameter variable\">&#8211;yes<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>This command generates a basic package.json file which serves as the configuration file for your npm project.<\/p>\n<p>You will get the mentioned output.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">Output<\/div>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Wrote to \/Users\/<mark>your_username<\/mark>\/workspace\/prisma-graphql\/package.json: { &#8220;name&#8221;: &#8220;prisma-graphql&#8221;, &#8220;version&#8221;: &#8220;1.0.0&#8221;, &#8220;description&#8221;: &#8220;&#8221;, &#8220;main&#8221;: &#8220;index.js&#8221;, &#8220;scripts&#8221;: { &#8220;test&#8221;: &#8220;echo \\&#8221;Error: no test specified\\&#8221; &amp;&amp; exit 1&#8243; }, &#8220;keywords&#8221;: [], &#8220;author&#8221;: &#8220;&#8221;, &#8220;license&#8221;: &#8220;ISC&#8221; }<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>You are now prepared to set up TypeScript in your project.<\/p>\n<p>Please install the required dependencies.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">npm<\/span> <span class=\"token function\">install<\/span> apollo-server graphql <span class=\"token parameter variable\">&#8211;save<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>This instruction will add two packages to your project&#8217;s dependencies during installation.<\/p>\n<ul class=\"post-ul\">\n<li>apollo-server is the HTTP library that you use to define how GraphQL requests are resolved and how to fetch data.<\/li>\n<li>graphql is the library you\u2019ll use to build the GraphQL schema.<\/li>\n<\/ul>\n<p>Once you have successfully set up your project and installed the necessary dependencies, the subsequent task involves defining the GraphQL schema.<\/p>\n<h2>Second Step \u2014 Establishing the GraphQL Schema and Resolvers<\/h2>\n<p>In this stage, you will be creating the GraphQL schema and its corresponding resolvers. The schema will outline the operations that the API can perform. The resolvers will determine how these requests are handled, utilizing in-memory data structures that will later be substituted with database queries.<\/p>\n<p>To begin with, generate a fresh directory named src to store all of your source files.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">mkdir<\/span> src<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Next, execute the given command to generate the file for the schema.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> src\/schema.js<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>You should include the code provided into the document.<\/p>\n<div>In the prisma-graphql directory, navigate to the schema.js file.<\/div>\n<pre class=\"post-pre\"><code><span class=\"token keyword\">const<\/span> <span class=\"token punctuation\">{<\/span> gql <span class=\"token punctuation\">}<\/span> <span class=\"token operator\">=<\/span> <span class=\"token function\">require<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">'apollo-server'<\/span><span class=\"token punctuation\">)<\/span>\r\n\r\n<span class=\"token keyword\">const<\/span> typeDefs <span class=\"token operator\">=<\/span> gql<span class=\"token template-string\"><span class=\"token template-punctuation string\">`<\/span><span class=\"token graphql language-graphql\">\r\n  <span class=\"token keyword\">type<\/span> <span class=\"token class-name\">Post<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token attr-name\">content<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">String<\/span>\r\n    <span class=\"token attr-name\">id<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">ID<\/span><span class=\"token operator\">!<\/span>\r\n    <span class=\"token attr-name\">published<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">Boolean<\/span><span class=\"token operator\">!<\/span>\r\n    <span class=\"token attr-name\">title<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">String<\/span><span class=\"token operator\">!<\/span>\r\n  <span class=\"token punctuation\">}<\/span>\r\n\r\n  <span class=\"token keyword\">type<\/span> <span class=\"token class-name\">Query<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token attr-name\">feed<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token class-name\">Post<\/span><span class=\"token operator\">!<\/span><span class=\"token punctuation\">]<\/span><span class=\"token operator\">!<\/span>\r\n    <span class=\"token attr-name\">post<\/span><span class=\"token punctuation\">(<\/span><span class=\"token attr-name\">id<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">ID<\/span><span class=\"token operator\">!<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token class-name\">Post<\/span>\r\n  <span class=\"token punctuation\">}<\/span>\r\n\r\n  <span class=\"token keyword\">type<\/span> <span class=\"token class-name\">Mutation<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token attr-name\">createDraft<\/span><span class=\"token punctuation\">(<\/span><span class=\"token attr-name\">content<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">String<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token attr-name\">title<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">String<\/span><span class=\"token operator\">!<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token class-name\">Post<\/span><span class=\"token operator\">!<\/span>\r\n    <span class=\"token attr-name\">publish<\/span><span class=\"token punctuation\">(<\/span><span class=\"token attr-name\">id<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">ID<\/span><span class=\"token operator\">!<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token class-name\">Post<\/span>\r\n  <span class=\"token punctuation\">}<\/span>\r\n<\/span><span class=\"token template-punctuation string\">`<\/span><\/span>\r\n<\/code><\/pre>\n<p>The gql tagged template is used to specify the GraphQL schema. It encompasses a set of type definitions (typeDefs), which collectively determine the structure of the queries that can be run on your API. Consequently, this will transform the GraphQL schema string into the format anticipated by Apollo.<\/p>\n<p>The schema presents three categories.<\/p>\n<ul class=\"post-ul\">\n<li>Post defines the type for a post in your blogging app and contains four fields where each field is followed by its type: for example, String.<\/li>\n<li>Query defines the feed query which returns multiple posts as denoted by the square brackets and the post query which accepts a single argument and returns a single Post.<\/li>\n<li>Mutation defines the createDraft mutation for creating a draft Post and the publish mutation which accepts an id and returns a Post.<\/li>\n<\/ul>\n<p>Each GraphQL API includes a query type and potentially a mutation type. These types function like regular object types but hold a unique role as they define the initial point for every GraphQL query.<\/p>\n<p>Afterwards, you can include the posts array in the src\/schema.js file, positioned under the typeDefs variable.<\/p>\n<div>prisma-graphql&#8217;s schema can be found in the location src\/schema.js.<\/div>\n<pre class=\"post-pre\"><code><span class=\"token operator\">...<\/span>\r\n<span class=\"token keyword\">const<\/span> posts <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">[<\/span>\r\n  <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token literal-property property\">id<\/span><span class=\"token operator\">:<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span>\r\n    <span class=\"token literal-property property\">title<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">'Subscribe to GraphQL Weekly for community news '<\/span><span class=\"token punctuation\">,<\/span>\r\n    <span class=\"token literal-property property\">content<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">'https:\/\/graphqlweekly.com\/'<\/span><span class=\"token punctuation\">,<\/span>\r\n    <span class=\"token literal-property property\">published<\/span><span class=\"token operator\">:<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">,<\/span>\r\n  <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n  <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token literal-property property\">id<\/span><span class=\"token operator\">:<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">,<\/span>\r\n    <span class=\"token literal-property property\">title<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">'Follow Silicon Cloud on Twitter'<\/span><span class=\"token punctuation\">,<\/span>\r\n    <span class=\"token literal-property property\">content<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">'https:\/\/twitter.com\/digitalocean'<\/span><span class=\"token punctuation\">,<\/span>\r\n    <span class=\"token literal-property property\">published<\/span><span class=\"token operator\">:<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">,<\/span>\r\n  <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n  <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token literal-property property\">id<\/span><span class=\"token operator\">:<\/span> <span class=\"token number\">3<\/span><span class=\"token punctuation\">,<\/span>\r\n    <span class=\"token literal-property property\">title<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">'What is GraphQL?'<\/span><span class=\"token punctuation\">,<\/span>\r\n    <span class=\"token literal-property property\">content<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">'GraphQL is a query language for APIs'<\/span><span class=\"token punctuation\">,<\/span>\r\n    <span class=\"token literal-property property\">published<\/span><span class=\"token operator\">:<\/span> <span class=\"token boolean\">false<\/span><span class=\"token punctuation\">,<\/span>\r\n  <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n<span class=\"token punctuation\">]<\/span>\r\n<\/code><\/pre>\n<p>You initialize the posts array with three predefined posts. Each post object follows the structure defined by the Post type in the schema. This array contains the posts that will be provided through the API. Later on, you will update the array when the database and Prisma Client are introduced.<\/p>\n<p>Afterwards, you can establish the resolvers object by inserting the subsequent code underneath the recently declared posts array:<\/p>\n<div>src\/schema.js in prisma-graphql.<\/div>\n<pre class=\"post-pre\"><code><span class=\"token operator\">...<\/span>\r\n<span class=\"token keyword\">const<\/span> resolvers <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">{<\/span>\r\n  <span class=\"token literal-property property\">Query<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token function-variable function\">feed<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">parent<span class=\"token punctuation\">,<\/span> args<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> <span class=\"token punctuation\">{<\/span>\r\n      <span class=\"token keyword\">return<\/span> posts<span class=\"token punctuation\">.<\/span><span class=\"token function\">filter<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token parameter\">post<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> post<span class=\"token punctuation\">.<\/span>published<span class=\"token punctuation\">)<\/span>\r\n    <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n    <span class=\"token function-variable function\">post<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">parent<span class=\"token punctuation\">,<\/span> args<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> <span class=\"token punctuation\">{<\/span>\r\n      <span class=\"token keyword\">return<\/span> posts<span class=\"token punctuation\">.<\/span><span class=\"token function\">find<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token parameter\">post<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> post<span class=\"token punctuation\">.<\/span>id <span class=\"token operator\">===<\/span> <span class=\"token function\">Number<\/span><span class=\"token punctuation\">(<\/span>args<span class=\"token punctuation\">.<\/span>id<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span>\r\n    <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n  <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n  <span class=\"token literal-property property\">Mutation<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token function-variable function\">createDraft<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">parent<span class=\"token punctuation\">,<\/span> args<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> <span class=\"token punctuation\">{<\/span>\r\n      posts<span class=\"token punctuation\">.<\/span><span class=\"token function\">push<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span>\r\n        <span class=\"token literal-property property\">id<\/span><span class=\"token operator\">:<\/span> posts<span class=\"token punctuation\">.<\/span>length <span class=\"token operator\">+<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span>\r\n        <span class=\"token literal-property property\">title<\/span><span class=\"token operator\">:<\/span> args<span class=\"token punctuation\">.<\/span>title<span class=\"token punctuation\">,<\/span>\r\n        <span class=\"token literal-property property\">content<\/span><span class=\"token operator\">:<\/span> args<span class=\"token punctuation\">.<\/span>content<span class=\"token punctuation\">,<\/span>\r\n        <span class=\"token literal-property property\">published<\/span><span class=\"token operator\">:<\/span> <span class=\"token boolean\">false<\/span><span class=\"token punctuation\">,<\/span>\r\n      <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span>\r\n      <span class=\"token keyword\">return<\/span> posts<span class=\"token punctuation\">[<\/span>posts<span class=\"token punctuation\">.<\/span>length <span class=\"token operator\">-<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">]<\/span>\r\n    <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n    <span class=\"token function-variable function\">publish<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">parent<span class=\"token punctuation\">,<\/span> args<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> <span class=\"token punctuation\">{<\/span>\r\n      <span class=\"token keyword\">const<\/span> postToPublish <span class=\"token operator\">=<\/span> posts<span class=\"token punctuation\">.<\/span><span class=\"token function\">find<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token parameter\">post<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> post<span class=\"token punctuation\">.<\/span>id <span class=\"token operator\">===<\/span> <span class=\"token function\">Number<\/span><span class=\"token punctuation\">(<\/span>args<span class=\"token punctuation\">.<\/span>id<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span>\r\n      postToPublish<span class=\"token punctuation\">.<\/span>published <span class=\"token operator\">=<\/span> <span class=\"token boolean\">true<\/span>\r\n      <span class=\"token keyword\">return<\/span> postToPublish\r\n    <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n  <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n  <span class=\"token literal-property property\">Post<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token function-variable function\">content<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">parent<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> parent<span class=\"token punctuation\">.<\/span>content<span class=\"token punctuation\">,<\/span>\r\n    <span class=\"token function-variable function\">id<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">parent<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> parent<span class=\"token punctuation\">.<\/span>id<span class=\"token punctuation\">,<\/span>\r\n    <span class=\"token function-variable function\">published<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">parent<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> parent<span class=\"token punctuation\">.<\/span>published<span class=\"token punctuation\">,<\/span>\r\n    <span class=\"token function-variable function\">title<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">parent<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> parent<span class=\"token punctuation\">.<\/span>title<span class=\"token punctuation\">,<\/span>\r\n  <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n<span class=\"token punctuation\">}<\/span>\r\n\r\nmodule<span class=\"token punctuation\">.<\/span>exports <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">{<\/span>\r\n  resolvers<span class=\"token punctuation\">,<\/span>\r\n  typeDefs<span class=\"token punctuation\">,<\/span>\r\n<span class=\"token punctuation\">}<\/span>\r\n<\/code><\/pre>\n<p>The resolvers are defined in the same structure as the GraphQL schema. Each field in the schema&#8217;s types is associated with a resolver function that is responsible for providing the data for that field in your schema. For instance, the resolver function for Query.feed() will filter the posts array and return the published posts.<\/p>\n<p>Four arguments are received by resolver functions.<\/p>\n<ul class=\"post-ul\">\n<li>parent is the return value of the previous resolver in the resolver chain. For top-level resolvers, the parent is undefined, because no previous resolver is called. For example, when making a feed query, the query.feed() resolver will be called with parent\u2019s value undefined and then the resolvers of Post will be called where parent is the object returned from the feed resolver.<\/li>\n<li>args carries the parameters for the query. For example, the post query, will receive the id of the post to be fetched.<\/li>\n<li>context is an object that gets passed through the resolver chain that each resolver can write to and read from, which allows the resolvers to share information.<\/li>\n<li>info is an AST representation of the query or mutation. You can read more about the details in this Prisma series on GraphQL Basics.<\/li>\n<\/ul>\n<p>Only the parent and args are defined in these resolvers, so context and info are not required.<\/p>\n<p>Once you have completed your work, save the file and exit.<\/p>\n<div class=\"post-conf-note\">\n<p class=\"post-conf-desc\">Note<\/p>\n<div>\n<p>Please note that when a resolver returns a field with the same name as the resolver itself, such as the four resolvers for &#8220;Post&#8221;, Apollo Server will handle the resolution automatically. Therefore, you do not need to explicitly define these resolvers. Here is an example:<\/p>\n<p>&#8220;`<br \/>\nPost: {<br \/>\ncontent: (parent) =&gt; parent.content,<br \/>\nid: (parent) =&gt; parent.id,<br \/>\npublished: (parent) =&gt; parent.published,<br \/>\ntitle: (parent) =&gt; parent.title,<br \/>\n},<br \/>\n&#8220;`<\/p>\n<\/div>\n<\/div>\n<p>In order to instantiate the server with Apollo Server in the next step, you export the schema and resolvers for utilization.<\/p>\n<h2>Step 3 involves the creation of the GraphQL Server.<\/h2>\n<p>During this stage, you will generate the GraphQL server using Apollo Server and link it to a specific port to enable the server in accepting connections.<\/p>\n<p>To begin with, execute the following command in order to generate the server file.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> src\/server.js<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Include the subsequent code in the file.<\/p>\n<div>Serve the server.js file from the prisma-graphql\/src directory.<\/div>\n<pre class=\"post-pre\"><code><span class=\"token keyword\">const<\/span> <span class=\"token punctuation\">{<\/span> ApolloServer <span class=\"token punctuation\">}<\/span> <span class=\"token operator\">=<\/span> <span class=\"token function\">require<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">'apollo-server'<\/span><span class=\"token punctuation\">)<\/span>\r\n<span class=\"token keyword\">const<\/span> <span class=\"token punctuation\">{<\/span> resolvers<span class=\"token punctuation\">,<\/span> typeDefs <span class=\"token punctuation\">}<\/span> <span class=\"token operator\">=<\/span> <span class=\"token function\">require<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">'.\/schema'<\/span><span class=\"token punctuation\">)<\/span>\r\n\r\n<span class=\"token keyword\">const<\/span> port <span class=\"token operator\">=<\/span> process<span class=\"token punctuation\">.<\/span>env<span class=\"token punctuation\">.<\/span><span class=\"token constant\">PORT<\/span> <span class=\"token operator\">||<\/span> <span class=\"token number\">8080<\/span>\r\n\r\n<span class=\"token keyword\">new<\/span> <span class=\"token class-name\">ApolloServer<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span> resolvers<span class=\"token punctuation\">,<\/span> typeDefs <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">listen<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span> port <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span>\r\n  console<span class=\"token punctuation\">.<\/span><span class=\"token function\">log<\/span><span class=\"token punctuation\">(<\/span><span class=\"token template-string\"><span class=\"token template-punctuation string\">`<\/span><span class=\"token string\">Server ready at: http:\/\/localhost:<\/span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${<\/span>port<span class=\"token interpolation-punctuation punctuation\">}<\/span><\/span><span class=\"token template-punctuation string\">`<\/span><\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span>\r\n<span class=\"token punctuation\">)<\/span>\r\n<\/code><\/pre>\n<p>In this step, you create an instance of the server and provide the schema and resolvers that were used in the previous step.<\/p>\n<p>The server will be bound to the port specified in the PORT environment variable. If the variable is not set, the server will use the default port 8080. App Platform automatically sets the PORT environment variable, ensuring that your server can accept connections after deployment.<\/p>\n<p>Please save the file and proceed to exit.<\/p>\n<p>Your GraphQL API is prepared for execution. Begin the server by using the command provided below:<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">node<\/span> src\/server.js<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>You will get the output as follows.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">Output<\/div>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Server ready at: http:\/\/localhost:8080<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Including a starting script in your package.json file is commonly recognized as a best practice to ensure clarity in determining the server&#8217;s entry point. This step enables the server to be initiated upon deployment, as desired by the App Platform.<\/p>\n<p>To start, halt the server by pressing CTRL+C. Next, access the package.json file to include a script for initiating the server.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> package.json<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Include the designated text in the &#8220;scripts&#8221; section of package.json.<\/p>\n<div>package.json is a file that contains the configurations and dependencies for a JavaScript project.<\/div>\n<pre class=\"post-pre\"><code><span class=\"token punctuation\">{<\/span>\r\n  <span class=\"token property\">\"name\"<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">\"prisma-graphql\"<\/span><span class=\"token punctuation\">,<\/span>\r\n  <span class=\"token property\">\"version\"<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">\"1.0.0\"<\/span><span class=\"token punctuation\">,<\/span>\r\n  <span class=\"token property\">\"description\"<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">\"\"<\/span><span class=\"token punctuation\">,<\/span>\r\n  <span class=\"token property\">\"main\"<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">\"index.js\"<\/span><span class=\"token punctuation\">,<\/span>\r\n  <span class=\"token property\">\"scripts\"<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token property\">\"test\"<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">\"echo \\\"Error: no test specified\\\" &amp;&amp; exit 1\"<\/span><mark><span class=\"token punctuation\">,<\/span><\/mark>\r\n    <mark><span class=\"token property\">\"start\"<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">\"node .\/src\/server.js\"<\/span><\/mark>\r\n  <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n  <span class=\"token property\">\"keywords\"<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span>\r\n  <span class=\"token property\">\"author\"<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">\"\"<\/span><span class=\"token punctuation\">,<\/span>\r\n  <span class=\"token property\">\"license\"<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">\"ISC\"<\/span><span class=\"token punctuation\">,<\/span>\r\n  <span class=\"token property\">\"dependencies\"<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token property\">\"apollo-server\"<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">\"^3.11.1\"<\/span><span class=\"token punctuation\">,<\/span>\r\n    <span class=\"token property\">\"graphql\"<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">\"^16.6.0\"<\/span>\r\n  <span class=\"token punctuation\">}<\/span>\r\n<span class=\"token punctuation\">}<\/span>\r\n<\/code><\/pre>\n<p>Please save the file and then close it.<\/p>\n<p>You can now initiate the server using this command.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">npm<\/span> start<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>You are going to get the subsequent outcome.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">Output<\/div>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&gt; prisma-graphql@1.0.0 start &gt; node .\/src\/server.js Server ready at: http:\/\/localhost:8080<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>In order to examine the GraphQL API, access the URL provided in the result, which will direct you to the Apollo GraphQL Studio. Press the Query Your Server button on the main page to engage with the IDE.<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/655c6abdc40ba52feef1d6e8\/83-0.png\" alt=\"Apollo GraphQL Studio\" \/><\/div>\n<p>You can use the Apollo GraphQL Studio, an IDE, to evaluate the API by dispatching queries and mutations.<\/p>\n<p>To test the feed query, which fetches only published posts, simply input the given query on the left side of the IDE and execute it by clicking the Run or play button.<\/p>\n<pre class=\"post-pre\"><code><span class=\"token keyword\">query<\/span> <span class=\"token punctuation\">{<\/span>\r\n  <span class=\"token object\">feed<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token property\">id<\/span>\r\n    <span class=\"token property\">title<\/span>\r\n    <span class=\"token property\">content<\/span>\r\n    <span class=\"token property\">published<\/span>\r\n  <span class=\"token punctuation\">}<\/span>\r\n<span class=\"token punctuation\">}<\/span>\r\n<\/code><\/pre>\n<p>The reply will show the title &#8220;Subscribe to GraphQL Weekly&#8221; along with its URL, and &#8220;Follow Silicon Cloud on Twitter&#8221; along with its URL.<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/655c6abdc40ba52feef1d6e8\/88-0.png\" alt=\"GraphQL Feed Query\" \/><\/div>\n<p>To create a new tab, simply click the + button on the bar above your previous query. Once done, input the createDraft mutation you want to test.<\/p>\n<pre class=\"post-pre\"><code><span class=\"token keyword\">mutation<\/span> <span class=\"token punctuation\">{<\/span>\r\n  <span class=\"token property-query property-mutation\">createDraft<\/span><span class=\"token punctuation\">(<\/span><span class=\"token attr-name\">title<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">\"Deploying a GraphQL API to Silicon Cloud\"<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token property\">id<\/span>\r\n    <span class=\"token property\">title<\/span>\r\n    <span class=\"token property\">content<\/span>\r\n    <span class=\"token property\">published<\/span>\r\n  <span class=\"token punctuation\">}<\/span>\r\n<span class=\"token punctuation\">}<\/span>\r\n<\/code><\/pre>\n<p>Once you click on the play button to submit the mutation, you will receive a response that includes the title &#8220;Deploying a GraphQL API to Silicon Cloud.&#8221;<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/655c6abdc40ba52feef1d6e8\/92-0.png\" alt=\"GraphQL Create Draft Mutation\" \/><\/div>\n<div class=\"post-conf-note\">\n<p class=\"post-conf-desc\">Note<\/p>\n<div>You have the option to select the fields you want to retrieve from the createDraft mutation. Simply add or remove the desired fields inside the curly braces ({}) after createDraft. For instance, if you only wish to receive the id and title, you can use the following mutation:<br \/>\nmutation {<br \/>\ncreateDraft(title: &#8220;Deploying a GraphQL API to Silicon Cloud&#8221;) {<br \/>\nid<br \/>\ntitle<br \/>\n}<br \/>\n}<\/div>\n<\/div>\n<p>You have successfully developed and verified the GraphQL server. The next task is to establish a GitHub repository for the project.<\/p>\n<h2>Step 4 involves the creation of the GitHub Repository.<\/h2>\n<p>In this phase, you will establish a GitHub repository for your project and upload your modifications. This will facilitate the automatic deployment of the GraphQL API from GitHub to the App Platform.<\/p>\n<p>To begin with, halt the development server by pressing the CTRL+C key combination. Subsequently, initiate a repository in the prisma-graphql folder by executing the given command.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">git<\/span> init<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Afterward, employ the subsequent two commands to save the code to the repository.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">git<\/span> <span class=\"token function\">add<\/span> src package-lock.json package.json<\/li>\n<li data-prefix=\"$\"><span class=\"token function\">git<\/span> commit <span class=\"token parameter variable\">-m<\/span> <span class=\"token string\">&#8216;Initial commit&#8217;<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Once you have successfully saved the modifications to your local repository, proceed to create a repository on GitHub and upload the changes you made.<\/p>\n<p>Head over to GitHub and generate a fresh repository, ensuring that you name it prisma-graphql, then simply hit the Create repository button.<\/p>\n<p>Once the repository is established, utilize the below commands to push the modifications, including the action of renaming the default local branch to main.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">git<\/span> remote <span class=\"token function\">add<\/span> origin git@github.com:<mark>your_github_username<\/mark>\/prisma-graphql.git<\/li>\n<li data-prefix=\"$\"><span class=\"token function\">git<\/span> branch <span class=\"token parameter variable\">-M<\/span> main<\/li>\n<li data-prefix=\"$\"><span class=\"token function\">git<\/span> push &#8211;set-upstream origin main<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Once the changes have been successfully committed and pushed to GitHub, the next step is to link the repository with App Platform and deploy the GraphQL API.<\/p>\n<h2>Step 5 &#8211; The next step involves deploying the application to the App Platform.<\/h2>\n<p>In this phase, you will establish a connection between the GitHub repository you recently set up and Silicon Cloud. Afterwards, configure the App Platform in a manner that enables automatic deployment of the GraphQL API whenever you make changes and push them to GitHub.<\/p>\n<p>To begin, navigate to the App Platform section in the Silicon Cloud Cloud Console and select the Create App option.<\/p>\n<p>By default, GitHub will be presented as the service provider, along with other available options for you to choose from.<\/p>\n<p>If you haven&#8217;t set up Silicon Cloud to work with your GitHub account yet, simply click on the Manage Access button and you will be redirected to GitHub.<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/655c6abdc40ba52feef1d6e8\/111-0.png\" alt=\"Silicon Cloud Cloud console page for \" \/><\/div>\n<p>You have the option to choose either all repositories or specific repositories. Once you click on &#8220;Install &amp; Authorize,&#8221; you will be redirected back to the creation page of the Silicon Cloud App Platform.<\/p>\n<p>Select the repository\u00a0prisma-graphql under your GitHub username and proceed by clicking on &#8220;Next&#8221;. The autodeploy option is already chosen by default, so you can keep it selected to ensure consistency during future redeployments.<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/655c6abdc40ba52feef1d6e8\/114-0.png\" alt=\"Choose Repository\" \/><\/div>\n<p>On the Resources page, simply click on the Edit Plan button to select a plan that fits your requirements. Opt for the Basic plan with the desired plan size (this tutorial will demonstrate the utilization of the $5.00 per month &#8211; Basic plan).<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/655c6abdc40ba52feef1d6e8\/116-0.png\" alt=\"Screencapture of the \" \/><\/div>\n<p>Simply press the Back button in order to go back to the creation page.<\/p>\n<p>By selecting the pen symbol next to your project&#8217;s name, you can personalize the app&#8217;s setup. This action will prompt the opening of the Application Settings page.<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/655c6abdc40ba52feef1d6e8\/119-0.png\" alt=\"Application Settings\" \/><\/div>\n<p>Make sure that the Run Command is set to npm start. By default, App Platform will set the HTTP port to 8080, which is also the port you have specified for your GraphQL server to connect with.<\/p>\n<p>Once you are done personalizing the settings, click on the Back button to go back to the setup page. Then, click on the Next button to proceed to the Environment Variables page.<\/p>\n<p>Currently, there is no need for additional configuration of your environment variables. Simply click the Next button.<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/655c6abdc40ba52feef1d6e8\/123-0.png\" alt=\"Screencapture displaying the Environment Variables default setup\" \/><\/div>\n<p>You can customize the App Details and Location on the Info page. Modify your app information to select the desired deployment region. Save your app details by clicking the Save button. Afterward, proceed to the Next button.<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/655c6abdc40ba52feef1d6e8\/125-0.png\" alt=\"Screencapture of the Info page, displaying the selected location of the application\" \/><\/div>\n<p>Once you have chosen your preferred options, you can access them on the Review page. After reviewing, click on Create Resources. This will take you to the application page, where you can observe the initial deployment progress.<\/p>\n<p>Once the compilation is completed, you will receive a notification signifying the deployment of your application.<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/655c6abdc40ba52feef1d6e8\/128-0.png\" alt=\"Screencapture displaying the deployment progress bar with a \" \/><\/div>\n<p>You can access your deployed GraphQL API by visiting the URL below the app&#8217;s name in your Silicon Cloud Console. The URL will be connected through the ondigitalocean.app subdomain. Opening the URL will bring up the GraphQL Playground, just like in Step 3 of this tutorial.<\/p>\n<p>Once your repository is linked to App Platform and your GraphQL API is deployed, you can proceed to enhance your application by substituting the in-memory data of the GraphQL API with a database.<\/p>\n<h2>Step 6 involves configuring Prisma to work with PostgreSQL.<\/h2>\n<p>Up until now, you have developed a GraphQL API that utilizes the in-memory posts array for data storage. However, any modifications made to the data will be erased if the server restarts. To guarantee the secure persistence of your data, you will substitute the posts array with a PostgreSQL database and employ Prisma for data access.<\/p>\n<p>In this stage, you will carry out the installation of the Prisma CLI, generate your initial Prisma schema (the principal setup file for your Prisma setup, which comprises your database schema), configure PostgreSQL with Docker on your local system, and establish Prisma&#8217;s connection to it.<\/p>\n<p>To start, initiate the installation of the Prisma CLI using this command:<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">npm<\/span> <span class=\"token function\">install<\/span> &#8211;save-dev prisma<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>The Prisma CLI assists in managing database tasks like executing database migrations and creating Prisma Client.<\/p>\n<p>Afterwards, you will configure your PostgreSQL database by utilizing Docker. Generate a fresh Docker Compose file by running the given command:<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> docker-compose.yml<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Include the provided code into the recently established file.<\/p>\n<div>\n<p>prisma-graphql\/docker-compose.yml can be rephrased as:<\/p>\n<p>The docker-compose.yml file for prisma-graphql.<\/p>\n<\/div>\n<pre class=\"post-pre\"><code><span class=\"token key atrule\">version<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">'3.8'<\/span>\r\n<span class=\"token key atrule\">services<\/span><span class=\"token punctuation\">:<\/span>\r\n  <span class=\"token key atrule\">postgres<\/span><span class=\"token punctuation\">:<\/span>\r\n    <span class=\"token key atrule\">image<\/span><span class=\"token punctuation\">:<\/span> postgres<span class=\"token punctuation\">:<\/span><span class=\"token number\">14<\/span>\r\n    <span class=\"token key atrule\">restart<\/span><span class=\"token punctuation\">:<\/span> always\r\n    <span class=\"token key atrule\">environment<\/span><span class=\"token punctuation\">:<\/span>\r\n      <span class=\"token punctuation\">-<\/span> POSTGRES_USER=<mark>test<span class=\"token punctuation\">-<\/span>user<\/mark>\r\n      <span class=\"token punctuation\">-<\/span> POSTGRES_PASSWORD=<mark>test<span class=\"token punctuation\">-<\/span>password<\/mark>\r\n    <span class=\"token key atrule\">volumes<\/span><span class=\"token punctuation\">:<\/span>\r\n      <span class=\"token punctuation\">-<\/span> postgres<span class=\"token punctuation\">:<\/span>\/var\/lib\/postgresql\/data\r\n    <span class=\"token key atrule\">ports<\/span><span class=\"token punctuation\">:<\/span>\r\n      <span class=\"token punctuation\">-<\/span> <span class=\"token string\">'5432:5432'<\/span>\r\n<span class=\"token key atrule\">volumes<\/span><span class=\"token punctuation\">:<\/span>\r\n  <span class=\"token key atrule\">postgres<\/span><span class=\"token punctuation\">:<\/span>\r\n<\/code><\/pre>\n<p>This native paraphrase of the given sentence could be:<br \/>\nThe purpose of this Docker Compose configuration file is to initiate the official PostgreSQL Docker image on your local device. The environment variables POSTGRES_USER and POSTGRES_PASSWORD are utilized for establishing the superuser&#8217;s credentials, granting administrative privileges. These same credentials will be employed to connect Prisma with the database. So, kindly update the test-user and test-password with your own user credentials.<\/p>\n<p>Ultimately, you designate a storage location for PostgreSQL to store its data and connect the port 5432 on your device to the equivalent port in the Docker container.<\/p>\n<p>Please save the file and then exit.<\/p>\n<p>Once you have set up this configuration, you can commence the PostgreSQL database server using the subsequent command.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">docker-compose<\/span> up <span class=\"token parameter variable\">-d<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>It might require a couple of minutes for the loading process.<\/p>\n<p>To ensure that the database server is operational, execute the given command.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">docker<\/span> <span class=\"token function\">ps<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>This instruction will produce a result that is comparable to:<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">Output<\/div>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 198f9431bf73 postgres:10.3 &#8220;docker-entrypoint.s\u2026&#8221; 45 seconds ago Up 11 seconds 0.0.0.0:5432-&gt;5432\/tcp prisma-graphql_postgres_1<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>After starting the PostgreSQL container, proceed to set up your Prisma. Execute the given command from the Prisma CLI.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\">npx prisma init<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>To ensure the use of your local installation, it is recommended to prefix all Prisma CLI invocations with npx.<\/p>\n<p>This will print an output as such:<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">Output<\/div>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u2714 Your Prisma schema was created at prisma\/schema.prisma You can now open it in your favorite editor. Next steps: 1. Set the DATABASE_URL in the .env file to point to your existing database. If your database has no tables yet, read https:\/\/pris.ly\/d\/getting-started 2. Set the provider of the datasource block in schema.prisma to match your database: postgresql, mysql, sqlite, sqlserver, mongodb or cockroachdb. 3. Run prisma db pull to turn your database schema into a Prisma schema. 4. Run prisma generate to generate the Prisma Client. You can then start querying your database. More information in our documentation: https:\/\/pris.ly\/d\/getting-started<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Once you execute the command, the Prisma CLI will create a .env file in the project folder to specify the database connection URL. Additionally, it will generate a new folder named prisma, which will hold the schema.prisma file. This file serves as the primary configuration file for your Prisma project, where you can define your data model.<\/p>\n<p>To ensure that Prisma is aware of the location of your database, access the .env file.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> .env<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Update the DATABASE_URL environment variable by adding your user credentials.<\/p>\n<div>.env file in the prisma-graphql project<\/div>\n<pre class=\"post-pre\"><code>DATABASE_URL=\"postgresql:\/\/<mark>test-user<\/mark>:<mark>test-password<\/mark>@localhost:5432\/<mark>my-blog<\/mark>?schema=public\"\r\n<\/code><\/pre>\n<p>To access the database, utilize the login details &#8220;test-user&#8221; and &#8220;test-password&#8221; mentioned in the Docker Compose file. If you make any changes to these credentials in your Docker Compose file, remember to modify this line accordingly with the updated credentials. For additional information on the connection URL format, refer to the Prisma documentation.<\/p>\n<p>You have performed the successful initiation of PostgreSQL and configured Prisma by implementing the Prisma schema. Now, in the subsequent phase, you will establish your data model for the blog and employ Prisma Migrate to generate the database schema.<\/p>\n<h2>In Step 7, we create the Data Model using Prisma Migrate.<\/h2>\n<p>Now, you will specify your data structure in the newly created Prisma schema file. This structure will be translated into the database using Prisma Migrate, which will automatically generate and execute the necessary SQL commands to create tables based on your data model.<\/p>\n<p>As you construct a blog, the fundamental components of the system will consist of users and posts. At this stage, your task is to establish a Post model that mirrors the structure of the Post type in the GraphQL schema. In a subsequent stage, you will progress further and introduce a User model.<\/p>\n<div class=\"post-conf-note\">\n<p class=\"post-conf-desc\">Note<\/p>\n<div>Please note that the GraphQL API can be viewed as a way to simplify your database. When creating a GraphQL API, it is typical for the GraphQL schema to closely match your database schema. However, since it is an abstraction, the two schemas may not have the exact same structure. This allows you to determine which data you want to make accessible through the API, as certain data may be considered sensitive or unnecessary for the API layer.<\/div>\n<\/div>\n<p>Prisma employs its unique data modeling language to specify the structure of your application&#8217;s data.<\/p>\n<p>Navigate to the location of the package.json file in your project&#8217;s folder and open the schema.prisma file.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> prisma\/schema.prisma<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"post-conf-note\">\n<p class=\"post-conf-desc\">Note<\/p>\n<div>Please note that you can use the pwd command in the terminal to check the current working directory. This will display the folder you are in. Moreover, you can use the ls command to see the files in the directory and navigate through your file system.<\/div>\n<\/div>\n<p>Include the subsequent model definitions in it.<\/p>\n<div>transform the file located at prisma-graphql\/prisma\/schema.prisma<\/div>\n<pre class=\"post-pre\"><code>...\r\nmodel Post {\r\n  id        Int     @default(autoincrement()) @id\r\n  title     String\r\n  content   String?\r\n  published Boolean @default(false)\r\n}\r\n<\/code><\/pre>\n<p>You create a Post model with various fields. This model will be associated with a database table, where each field corresponds to a column.<\/p>\n<p>The id fields possess the subsequent field characteristics:<\/p>\n<ul class=\"post-ul\">\n<li>@default(autoincrement()) sets an auto-incrementing default value for the column.<\/li>\n<li>@id sets the column as the primary key for the table.<\/li>\n<\/ul>\n<p>Please save the file and then exit.<\/p>\n<p>Once you have set up the model, you can proceed to generate the corresponding table in the database utilizing Prisma Migrate. Apply the &#8220;migrate dev&#8221; command to create and execute the migration files.<\/p>\n<p>Please execute the following command in your terminal.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\">npx prisma migrate dev <span class=\"token parameter variable\">&#8211;name<\/span> init &#8211;skip-generate<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>This instruction generates a fresh migration on your file system and executes it to produce the database schema. The &#8211;name init parameter determines the migration&#8217;s name, which will also be used as the name for the created migration folder on your file system. The &#8211;skip-generate parameter avoids the generation of Prisma Client, which will be done in the subsequent step.<\/p>\n<p>The result of this command will be something resembling:<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">Output<\/div>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Environment variables loaded from .env Prisma schema loaded from prisma\/schema.prisma Datasource &#8220;db&#8221;: PostgreSQL database &#8220;my-blog&#8221;, schema &#8220;public&#8221; at &#8220;localhost:5432&#8221; PostgreSQL database my-blog created at localhost:5432 Applying migration `<mark>20201201110111<\/mark>_init` The following migration(s) have been created and applied from new schema changes: migrations\/ \u2514\u2500 <mark>20201201110111<\/mark>_init\/ \u2514\u2500 migration.sql Your database is now in sync with your schema.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Now your prisma\/migrations directory contains the SQL migration file. This method enables you to monitor modifications made to the database schema and reproduce the exact same database schema in a production environment.<\/p>\n<div class=\"post-conf-note\">\n<p class=\"post-conf-desc\">Note<\/p>\n<div>If you have previously used Prisma Migrate with the my-blog database and there is a mismatch between the migrations in the prisma\/migration folder and the database schema, you will receive a prompt asking if you want to reset the database. The prompt will state that the PostgreSQL database &#8220;my-blog&#8221; located at &#8220;localhost:5432&#8221; will be reset and all data will be deleted. To proceed, you can enter &#8216;y&#8217;. Please be aware that choosing this option will result in the loss of all data in the database.<\/div>\n<\/div>\n<p>After successfully designing your database schema, the subsequent phase involves the installation of Prisma Client, which can be utilized in your GraphQL resolvers.<\/p>\n<h2>Step 8 involves utilizing Prisma Client within the GraphQL Resolvers.<\/h2>\n<p>You will incorporate Prisma Client, an automatically generated and secure Object Relational Mapper (ORM), into your Node.js application to facilitate programmatic reading and writing of data from a database. This step involves installing Prisma Client in your project.<\/p>\n<p>Please install the Prisma Client npm package in your terminal.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">npm<\/span> <span class=\"token function\">install<\/span> @prisma\/client<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"post-conf-note\">\n<p class=\"post-conf-desc\">Note<\/p>\n<div>Please note that Prisma Client offers convenient auto-completion by generating code in the node_modules folder, using your Prisma schema as a basis. To generate the code, simply use the npx prisma generate command. Usually, this is done after creating and executing a new migration. However, during the initial installation, there is no need to do this manually as it will be automatically generated for you through a postinstall hook.<\/div>\n<\/div>\n<p>Once you have set up the database and GraphQL schema and installed Prisma Client, you can utilize Prisma Client within the GraphQL resolvers to access and manipulate data in the database. This involves substituting the existing posts array, which has been serving as the data storage, with Prisma Client.<\/p>\n<p>Please generate and access the file mentioned below:<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> src\/db.js<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Include the subsequent lines in the fresh document:<\/p>\n<div>prisma-graphql&#8217;s source code for the database can be found at \/src\/db.js.<\/div>\n<pre class=\"post-pre\"><code><span class=\"token keyword\">const<\/span> <span class=\"token punctuation\">{<\/span> PrismaClient <span class=\"token punctuation\">}<\/span> <span class=\"token operator\">=<\/span> <span class=\"token function\">require<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">'@prisma\/client'<\/span><span class=\"token punctuation\">)<\/span>\r\n\r\nmodule<span class=\"token punctuation\">.<\/span>exports <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">{<\/span>\r\n  <span class=\"token literal-property property\">prisma<\/span><span class=\"token operator\">:<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token class-name\">PrismaClient<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span>\r\n<span class=\"token punctuation\">}<\/span>\r\n<\/code><\/pre>\n<p>This code is responsible for importing the Prisma Client module, initializing an instance of it, and then exporting the same instance for usage in your resolvers.<\/p>\n<p>Please save and exit the src\/db.js file.<\/p>\n<p>Afterwards, you need to import the prisma instance into src\/schema.js. To accomplish this, go ahead and open src\/schema.js.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> src\/schema.js<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>At the beginning of the file, include the following line to import prisma from the .\/db directory.<\/p>\n<div>The schema.js file in prisma-graphql\/src has to be paraphrased natively.<\/div>\n<pre class=\"post-pre\"><code><span class=\"token keyword\">const<\/span> <span class=\"token punctuation\">{<\/span> prisma <span class=\"token punctuation\">}<\/span> <span class=\"token operator\">=<\/span> <span class=\"token function\">require<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">'.\/db'<\/span><span class=\"token punctuation\">)<\/span>\r\n<span class=\"token operator\">...<\/span>\r\n<\/code><\/pre>\n<p>To eliminate the posts array, get rid of the lines that contain the hyphen symbol (-).<\/p>\n<div>Create a schema.js file within the prisma-graphql directory.<\/div>\n<pre class=\"post-pre\"><code>...\r\n<span class=\"token deleted-sign deleted\"><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">const posts = [\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">  {\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">    id: 1,\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">    title: 'Subscribe to GraphQL Weekly for community news ',\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">    content: 'https:\/\/graphqlweekly.com\/',\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">    published: true,\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">  },\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">  {\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">    id: 2,\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">    title: 'Follow Silicon Cloud on Twitter',\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">    content: 'https:\/\/twitter.com\/digitalocean',\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">    published: true,\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">  },\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">  {\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">    id: 3,\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">    title: 'What is GraphQL?',\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">    content: 'GraphQL is a query language for APIs',\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">    published: false,\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">  },\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">]\r\n<\/span><\/span>...\r\n<\/code><\/pre>\n<p>To fetch published posts from the database, you need to update the Query resolvers. Start by removing the current lines in the resolvers.Query, and then enhance the object by incorporating the highlighted lines.<\/p>\n<div>\n<p>One possible option for paraphrasing the given text could be:<\/p>\n<p>&#8220;The schema.js file can be found in the prisma-graphql directory.&#8221;<\/p>\n<\/div>\n<pre class=\"post-pre\"><code><span class=\"token operator\">...<\/span>\r\n<span class=\"token keyword\">const<\/span> resolvers <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">{<\/span>\r\n  <mark><span class=\"token literal-property property\">Query<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n    <mark><span class=\"token function-variable function\">feed<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">parent<span class=\"token punctuation\">,<\/span> args<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n      <mark><span class=\"token keyword\">return<\/span> prisma<span class=\"token punctuation\">.<\/span>post<span class=\"token punctuation\">.<\/span><span class=\"token function\">findMany<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span><\/mark>\r\n        <mark><span class=\"token literal-property property\">where<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token literal-property property\">published<\/span><span class=\"token operator\">:<\/span> <span class=\"token boolean\">true<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n      <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><\/mark>\r\n    <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n    <mark><span class=\"token function-variable function\">post<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">parent<span class=\"token punctuation\">,<\/span> args<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n      <mark><span class=\"token keyword\">return<\/span> prisma<span class=\"token punctuation\">.<\/span>post<span class=\"token punctuation\">.<\/span><span class=\"token function\">findUnique<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span><\/mark>\r\n        <mark><span class=\"token literal-property property\">where<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token literal-property property\">id<\/span><span class=\"token operator\">:<\/span> <span class=\"token function\">Number<\/span><span class=\"token punctuation\">(<\/span>args<span class=\"token punctuation\">.<\/span>id<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n      <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><\/mark>\r\n    <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n  <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n<span class=\"token operator\">...<\/span>\r\n<\/code><\/pre>\n<p>In this context, two Prisma Client queries are utilized.<\/p>\n<ul class=\"post-ul\">\n<li>findMany fetches posts whose publish field is false.<\/li>\n<li>findUnique fetches a single post whose id field equals the id GraphQL argument.<\/li>\n<\/ul>\n<p>According to the GraphQL specification, the ID type is serialized in the same manner as a String. As a result, you can convert it to a Number since the id in the Prisma schema is of type int.<\/p>\n<p>Afterwards, you will need to modify the Mutation resolver in order to store and modify posts in the database. Start by removing the code located within the resolvers.Mutation object as well as the Number(args.id) lines. Following that, incorporate the suggested lines.<\/p>\n<div>\n<p>Sure, here&#8217;s one possible paraphrase:<\/p>\n<p>&#8220;Schema.js located in the prisma-graphql directory.&#8221;<\/p>\n<\/div>\n<pre class=\"post-pre\"><code><span class=\"token keyword\">const<\/span> resolvers <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">{<\/span>\r\n  <span class=\"token operator\">...<\/span>\r\n  <mark><span class=\"token literal-property property\">Mutation<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n    <mark><span class=\"token function-variable function\">createDraft<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">parent<span class=\"token punctuation\">,<\/span> args<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n      <mark><span class=\"token keyword\">return<\/span> prisma<span class=\"token punctuation\">.<\/span>post<span class=\"token punctuation\">.<\/span><span class=\"token function\">create<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span><\/mark>\r\n        <mark><span class=\"token literal-property property\">data<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n          <mark><span class=\"token literal-property property\">title<\/span><span class=\"token operator\">:<\/span> args<span class=\"token punctuation\">.<\/span>title<span class=\"token punctuation\">,<\/span><\/mark>\r\n          <mark><span class=\"token literal-property property\">content<\/span><span class=\"token operator\">:<\/span> args<span class=\"token punctuation\">.<\/span>content<span class=\"token punctuation\">,<\/span><\/mark>\r\n        <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n      <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><\/mark>\r\n    <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n    <mark><span class=\"token function-variable function\">publish<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">parent<span class=\"token punctuation\">,<\/span> args<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n      <mark><span class=\"token keyword\">return<\/span> prisma<span class=\"token punctuation\">.<\/span>post<span class=\"token punctuation\">.<\/span><span class=\"token function\">update<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span><\/mark>\r\n        <mark><span class=\"token literal-property property\">where<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n          <mark><span class=\"token literal-property property\">id<\/span><span class=\"token operator\">:<\/span> <span class=\"token function\">Number<\/span><span class=\"token punctuation\">(<\/span>args<span class=\"token punctuation\">.<\/span>id<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n        <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n        <mark><span class=\"token literal-property property\">data<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n          <mark><span class=\"token literal-property property\">published<\/span><span class=\"token operator\">:<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n        <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n      <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><\/mark>\r\n    <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n  <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n<span class=\"token punctuation\">}<\/span>\r\n<\/code><\/pre>\n<p>You are utilizing two queries with Prisma Client.<\/p>\n<ul class=\"post-ul\">\n<li>create to create a Post record.<\/li>\n<li>update to update the published field of the Post record whose id matches the one in the query argument.<\/li>\n<\/ul>\n<p>In the end, eliminate the resolvers.Post entity.<\/p>\n<div>The schema file is located in prisma-graphql\/src\/schema.js.<\/div>\n<pre class=\"post-pre\"><code>...\r\n<span class=\"token deleted-sign deleted\"><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">Post: {\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">  content: (parent) =&gt; parent.content,\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">  id: (parent) =&gt; parent.id,\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">  published: (parent) =&gt; parent.published,\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">  title: (parent) =&gt; parent.title,\r\n<\/span><span class=\"token prefix deleted\">-<\/span><span class=\"token line\">},\r\n<\/span><\/span>...\r\n<\/code><\/pre>\n<p>Your schema.js should now be written in the following manner:<\/p>\n<div>\n<p>One possible paraphrase could be:<\/p>\n<p>&#8220;schema.js located in the prisma-graphql directory&#8221;<\/p>\n<\/div>\n<pre class=\"post-pre\"><code><span class=\"token keyword\">const<\/span> <span class=\"token punctuation\">{<\/span> gql <span class=\"token punctuation\">}<\/span> <span class=\"token operator\">=<\/span> <span class=\"token function\">require<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">'apollo-server'<\/span><span class=\"token punctuation\">)<\/span>\r\n<span class=\"token keyword\">const<\/span> <span class=\"token punctuation\">{<\/span> prisma <span class=\"token punctuation\">}<\/span> <span class=\"token operator\">=<\/span> <span class=\"token function\">require<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">'.\/db'<\/span><span class=\"token punctuation\">)<\/span>\r\n\r\n<span class=\"token keyword\">const<\/span> typeDefs <span class=\"token operator\">=<\/span> gql<span class=\"token template-string\"><span class=\"token template-punctuation string\">`<\/span><span class=\"token graphql language-graphql\">\r\n  <span class=\"token keyword\">type<\/span> <span class=\"token class-name\">Post<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token attr-name\">content<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">String<\/span>\r\n    <span class=\"token attr-name\">id<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">ID<\/span><span class=\"token operator\">!<\/span>\r\n    <span class=\"token attr-name\">published<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">Boolean<\/span><span class=\"token operator\">!<\/span>\r\n    <span class=\"token attr-name\">title<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">String<\/span><span class=\"token operator\">!<\/span>\r\n  <span class=\"token punctuation\">}<\/span>\r\n\r\n  <span class=\"token keyword\">type<\/span> <span class=\"token class-name\">Query<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token attr-name\">feed<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token class-name\">Post<\/span><span class=\"token operator\">!<\/span><span class=\"token punctuation\">]<\/span><span class=\"token operator\">!<\/span>\r\n    <span class=\"token attr-name\">post<\/span><span class=\"token punctuation\">(<\/span><span class=\"token attr-name\">id<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">ID<\/span><span class=\"token operator\">!<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token class-name\">Post<\/span>\r\n  <span class=\"token punctuation\">}<\/span>\r\n\r\n  <span class=\"token keyword\">type<\/span> <span class=\"token class-name\">Mutation<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token attr-name\">createDraft<\/span><span class=\"token punctuation\">(<\/span><span class=\"token attr-name\">content<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">String<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token attr-name\">title<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">String<\/span><span class=\"token operator\">!<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token class-name\">Post<\/span><span class=\"token operator\">!<\/span>\r\n    <span class=\"token attr-name\">publish<\/span><span class=\"token punctuation\">(<\/span><span class=\"token attr-name\">id<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">ID<\/span><span class=\"token operator\">!<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token class-name\">Post<\/span>\r\n  <span class=\"token punctuation\">}<\/span>\r\n<\/span><span class=\"token template-punctuation string\">`<\/span><\/span>\r\n\r\n<span class=\"token keyword\">const<\/span> resolvers <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">{<\/span>\r\n  <span class=\"token literal-property property\">Query<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token function-variable function\">feed<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">parent<span class=\"token punctuation\">,<\/span> args<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> <span class=\"token punctuation\">{<\/span>\r\n      <span class=\"token keyword\">return<\/span> prisma<span class=\"token punctuation\">.<\/span>post<span class=\"token punctuation\">.<\/span><span class=\"token function\">findMany<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span>\r\n        <span class=\"token literal-property property\">where<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token literal-property property\">published<\/span><span class=\"token operator\">:<\/span> <span class=\"token boolean\">true<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n      <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span>\r\n    <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n    <span class=\"token function-variable function\">post<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">parent<span class=\"token punctuation\">,<\/span> args<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> <span class=\"token punctuation\">{<\/span>\r\n      <span class=\"token keyword\">return<\/span> prisma<span class=\"token punctuation\">.<\/span>post<span class=\"token punctuation\">.<\/span><span class=\"token function\">findUnique<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span>\r\n        <span class=\"token literal-property property\">where<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token literal-property property\">id<\/span><span class=\"token operator\">:<\/span> <span class=\"token function\">Number<\/span><span class=\"token punctuation\">(<\/span>args<span class=\"token punctuation\">.<\/span>id<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n      <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span>\r\n    <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n  <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n  <span class=\"token literal-property property\">Mutation<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token function-variable function\">createDraft<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">parent<span class=\"token punctuation\">,<\/span> args<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> <span class=\"token punctuation\">{<\/span>\r\n      <span class=\"token keyword\">return<\/span> prisma<span class=\"token punctuation\">.<\/span>post<span class=\"token punctuation\">.<\/span><span class=\"token function\">create<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span>\r\n        <span class=\"token literal-property property\">data<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span>\r\n          <span class=\"token literal-property property\">title<\/span><span class=\"token operator\">:<\/span> args<span class=\"token punctuation\">.<\/span>title<span class=\"token punctuation\">,<\/span>\r\n          <span class=\"token literal-property property\">content<\/span><span class=\"token operator\">:<\/span> args<span class=\"token punctuation\">.<\/span>content<span class=\"token punctuation\">,<\/span>\r\n        <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n      <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span>\r\n    <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n    <span class=\"token function-variable function\">publish<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">parent<span class=\"token punctuation\">,<\/span> args<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> <span class=\"token punctuation\">{<\/span>\r\n      <span class=\"token keyword\">return<\/span> prisma<span class=\"token punctuation\">.<\/span>post<span class=\"token punctuation\">.<\/span><span class=\"token function\">update<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span>\r\n        <span class=\"token literal-property property\">where<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span>\r\n          <span class=\"token literal-property property\">id<\/span><span class=\"token operator\">:<\/span> <span class=\"token function\">Number<\/span><span class=\"token punctuation\">(<\/span>args<span class=\"token punctuation\">.<\/span>id<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span>\r\n        <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n        <span class=\"token literal-property property\">data<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span>\r\n          <span class=\"token literal-property property\">published<\/span><span class=\"token operator\">:<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">,<\/span>\r\n        <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n      <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span>\r\n    <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n  <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n<span class=\"token punctuation\">}<\/span>\r\n\r\nmodule<span class=\"token punctuation\">.<\/span>exports <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">{<\/span>\r\n  resolvers<span class=\"token punctuation\">,<\/span>\r\n  typeDefs<span class=\"token punctuation\">,<\/span>\r\n<span class=\"token punctuation\">}<\/span>\r\n<\/code><\/pre>\n<p>Please save the file and then close it.<\/p>\n<p>Once you have made the necessary changes to the resolvers by utilizing Prisma Client, you can initiate the server to examine how data flows between the GraphQL API and the database. Launch the server by executing the given command.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">npm<\/span> start<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Once more, you will be given the ensuing result.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">Output<\/div>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Server ready at: http:\/\/localhost:8080<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Go to the address provided in the output and use the Apollo GraphQL Studio to test the GraphQL API with the queries mentioned in Step 3.<\/p>\n<p>Now, you need to save your modifications in order for them to be implemented on App Platform. Use CTRL+C to stop the Apollo server.<\/p>\n<p>To prevent including the node_modules folder and .env file, review the .gitignore file located in your project directory.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">cat<\/span> .gitignore<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Please verify if the lines mentioned are present in your .gitignore file.<\/p>\n<div>.gitignore file in prisma-graphql.<\/div>\n<pre class=\"post-pre\"><code>node_modules\r\n.env\r\n<\/code><\/pre>\n<p>If it&#8217;s not the case, modify the file to correspond.<\/p>\n<p>Please save the file and then exit.<\/p>\n<p>Next, execute the subsequent two commands for committing the modifications.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">git<\/span> <span class=\"token function\">add<\/span> <span class=\"token builtin class-name\">.<\/span><\/li>\n<li data-prefix=\"$\"><span class=\"token function\">git<\/span> commit <span class=\"token parameter variable\">-m<\/span> <span class=\"token string\">&#8216;Add Prisma&#8217;<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>You will get a response output similar to this one.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">Output<\/div>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>git commit -m &#8216;Add Prisma&#8217; [main 1646d07] Add Prisma 9 files changed, 157 insertions(+), 39 deletions(-) create mode 100644 .gitignore create mode 100644 docker-compose.yml create mode 100644 prisma\/migrations\/<mark>20201201110111<\/mark>_init\/migration.sql create mode 100644 prisma\/migrations\/migration_lock.toml create mode 100644 prisma\/schema.prisma create mode 100644 src\/db.js<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>After incorporating the Prisma Client into your GraphQL resolvers for database queries and mutations, you have successfully pushed all the modifications to your remote repository. Now, your next step involves integrating a PostgreSQL database into your application on the App Platform.<\/p>\n<h2>Step 9 involves the creation and migration of the PostgreSQL database within the App Platform.<\/h2>\n<p>In this stage, you will integrate a PostgreSQL database into your application in App Platform. Next, you will utilize Prisma Migrate to execute the migration on this database, ensuring that the deployed database structure aligns with your local database.<\/p>\n<p>Initially, go to the App Platform console and choose the prisma-graphql project that you established in Step 5.<\/p>\n<p>Afterward, proceed to click the Create button and choose Create\/Attach Database from the dropdown menu. This selection will direct you to a page where you can configure your database.<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/655c6abdc40ba52feef1d6e8\/250-0.png\" alt=\"Screencapture displaying the Create\/Attach Database option in the dropdown menu\" \/><\/div>\n<p>Select the Dev Database of your choice, choose a name, and then click on the option to Create and Attach.<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/655c6abdc40ba52feef1d6e8\/252-0.png\" alt=\"\" \/><\/div>\n<p>Once you are redirected to the Project view, you will notice a progress bar indicating the creation of the database.<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/655c6abdc40ba52feef1d6e8\/254-0.png\" alt=\"Screencapture displaying the Creating Database Progress Bar\" \/><\/div>\n<p>Once you have created the database, you will execute the database migration on the Silicon Cloud production database from your local computer. In order to perform the migration, you will require the connection string for the hosted database.<\/p>\n<p>To access it, simply click on the db icon located in the Components section of the Settings tab.<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/655c6abdc40ba52feef1d6e8\/257-0.png\" alt=\"Screencapture displaying the Database Component Settings\" \/><\/div>\n<p>In Connection Details, click on View and then choose Connection String from the dropdown menu. Duplicate the database URL, which will be formatted as follows:<\/p>\n<pre class=\"post-pre\"><code>postgresql:\/\/db:<mark>some_password<\/mark>@<mark>unique_identifier<\/mark>.db.ondigitalocean.com:25060\/db?sslmode=require\r\n<\/code><\/pre>\n<p>Next, execute the given command in your terminal, making sure to replace &#8220;your_db_connection_string&#8221; with the URL you just copied.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token assign-left variable\">DATABASE_URL<\/span><span class=\"token operator\">=<\/span><span class=\"token string\">&#8220;<mark>your_db_connection_string<\/mark>&#8220;<\/span> npx prisma migrate deploy<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>With Prisma Migrate, executing this command will apply the migrations to the active database.<\/p>\n<p>If the migration is successful, you will get the following result.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">Output<\/div>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>PostgreSQL database db created at unique_identifier.db.ondigitalocean.com:25060 Prisma Migrate applied the following migration(s): migrations\/ \u2514\u2500 <mark>20201201110111<\/mark>_init\/ \u2514\u2500 migration.sql<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>The migration of the production database on Silicon Cloud has been successfully completed, and it now aligns with the Prisma schema.<\/p>\n<div class=\"post-conf-note\">\n<p class=\"post-conf-desc\">Note<\/p>\n<div>If you encounter the error message &#8220;OutputError: P1001: Unable to connect to the database server at `unique_identifier.db.ondigitalocean.com`:`25060`, please access the database dashboard to ensure that the database has been set up. It may be necessary to modify or deactivate the Trusted Sources for the database.<\/div>\n<\/div>\n<p>You can now launch your application by executing the given command to push your Git changes.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">git<\/span> push<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"post-conf-note\">\n<p class=\"post-conf-desc\">Note<\/p>\n<div>Please be aware that App Platform will provide the DATABASE_URL environment variable to your application during runtime. Prisma Client will utilize this environment variable by using env(&#8220;DATABASE_URL&#8221;) in the datasource block of your Prisma schema.<\/div>\n<\/div>\n<p>If you open the App Platform console, a build will be triggered automatically and you will be able to see the progress of the deployment through a progress bar.<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/655c6abdc40ba52feef1d6e8\/271-0.png\" alt=\"Screencapture displaying the Deployment Progress Bar\" \/><\/div>\n<p>After the successful deployment, you will be notified with a message confirming that the deployment has gone live.<\/p>\n<p>Now that you have safeguarded your deployed GraphQL API by creating a database backup, access the Live App to be directed to the Apollo GraphQL Studio. Proceed with evaluating the GraphQL API by employing the identical queries used in Step 3.<\/p>\n<p>In the last stage, you will enhance the GraphQL API by incorporating the User model.<\/p>\n<h2>Step 10: Including the User Model<\/h2>\n<p>In the process of enhancing your blogging GraphQL API, you will introduce a new model called User in the Prisma schema and adapt the GraphQL schema accordingly. By establishing a one-to-many relationship between the User and Post models, you can effectively depict the post authors and enable multiple posts to be associated with each user. Lastly, you will update the GraphQL schema to facilitate user creation and enable the association of posts with users through the API.<\/p>\n<p>To get started, access the Prisma schema file.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> prisma\/schema.prisma<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>To incorporate the authorId field into the Post model and establish the User model, include the highlighted lines.<\/p>\n<div>prisma-graphql\/prisma\/schema.prisma can be rephrased as &#8220;the schema.prisma file in the prisma-graphql repository&#8221;.<\/div>\n<pre class=\"post-pre\"><code>...\r\nmodel Post {\r\n  id        Int     @id @default(autoincrement())\r\n  title     String\r\n  content   String?\r\n  published Boolean @default(false)\r\n  <mark>author    User?   @relation(fields: [authorId], references: [id])<\/mark>\r\n  <mark>authorId  Int?<\/mark>\r\n}\r\n\r\n<mark>model User {<\/mark>\r\n  <mark>id    Int    @id @default(autoincrement())<\/mark>\r\n  <mark>email String @unique<\/mark>\r\n  <mark>name  String<\/mark>\r\n  <mark>posts Post[]<\/mark>\r\n<mark>}<\/mark>\r\n<\/code><\/pre>\n<p>You have included these items in the Prisma schema.<\/p>\n<ul class=\"post-ul\">\n<li>Two relation fields: author and posts. Relation fields define connections between models at the Prisma level and do not exist in the database. These fields are used to generate the Prisma Client and to access relations with Prisma Client.<\/li>\n<li>The authorId field, which is referenced by the @relation attribute. Prisma will create a foreign key in the database to connect Post and User.<\/li>\n<li>The User model to represent users.<\/li>\n<\/ul>\n<p>The author column in the Post model is not required, but it gives you the option to create posts that do not have any user associated with them.<\/p>\n<p>When you finish, save the file and then exit.<\/p>\n<p>After that, generate and execute the migration on your local device using the given command.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\">npx prisma migrate dev <span class=\"token parameter variable\">&#8211;name<\/span> <span class=\"token string\">&#8220;add-user&#8221;<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Once the migration is completed successfully, you will be notified with the following message.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">Output<\/div>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Environment variables loaded from .env Prisma schema loaded from prisma\/schema.prisma Datasource &#8220;db&#8221;: PostgreSQL database &#8220;my-blog&#8221;, schema &#8220;public&#8221; at &#8220;localhost:5432&#8221; Applying migration `<mark>20201201123056<\/mark>_add_user` The following migration(s) have been created and applied from new schema changes: migrations\/ \u2514\u2500 <mark>20201201123056<\/mark>_add_user\/ \u2514\u2500 migration.sql Your database is now in sync with your schema. \u2714 Generated Prisma Client (4.6.1 | library) to .\/node_modules\/@prisma\/client in 53ms<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Once the command is executed, Prisma Client is automatically created for utilizing the newly generated table and fields.<\/p>\n<p>Now, execute the migration on the production database on App Platform to ensure that the database schema matches your local database. Open your terminal and enter the following command, while configuring the DATABASE_URL with the connection URL from App Platform.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token assign-left variable\">DATABASE_URL<\/span><span class=\"token operator\">=<\/span><span class=\"token string\">&#8220;<mark>your_db_connection_string<\/mark>&#8220;<\/span> npx prisma migrate deploy<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>You will get the output mentioned below.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">Output<\/div>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Environment variables loaded from .env Prisma schema loaded from prisma\/schema.prisma Datasource &#8220;db&#8221;: PostgreSQL database &#8220;db&#8221;, schema &#8220;public&#8221; at &#8220;unique_identifier.db.ondigitalocean.com:25060&#8221; 2 migrations found in prisma\/migrations Applying migration `<mark>20201201123056<\/mark>_add_user` The following migration have been applied: migrations\/ \u2514\u2500 <mark>20201201123056<\/mark>_add_user\/ \u2514\u2500 migration.sql All migrations have been successfully applied.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>You need to update the GraphQL schema and resolvers with the latest changes made to the database schema.<\/p>\n<p>Please access the src\/schema.js file.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> src\/schema.js<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Modify typeDefs by incorporating the lines highlighted below:<\/p>\n<div>Can you please provide more context or specific information about the &#8220;prisma-graphql\/src\/schema.js&#8221; so that I can accurately paraphrase it?<\/div>\n<pre class=\"post-pre\"><code><span class=\"token operator\">...<\/span>\r\n<span class=\"token keyword\">const<\/span> typeDefs <span class=\"token operator\">=<\/span> gql<span class=\"token template-string\"><span class=\"token template-punctuation string\">`<\/span><span class=\"token graphql language-graphql\">\r\n  <mark><span class=\"token keyword\">type<\/span> <span class=\"token class-name\">User<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n    <mark><span class=\"token attr-name\">email<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">String<\/span><span class=\"token operator\">!<\/span><\/mark>\r\n    <mark><span class=\"token attr-name\">id<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">ID<\/span><span class=\"token operator\">!<\/span><\/mark>\r\n    <mark><span class=\"token attr-name\">name<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">String<\/span><\/mark>\r\n    <mark><span class=\"token attr-name\">posts<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token class-name\">Post<\/span><span class=\"token operator\">!<\/span><span class=\"token punctuation\">]<\/span><span class=\"token operator\">!<\/span><\/mark>\r\n  <mark><span class=\"token punctuation\">}<\/span><\/mark>\r\n\r\n  <span class=\"token keyword\">type<\/span> <span class=\"token class-name\">Post<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token attr-name\">content<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">String<\/span>\r\n    <span class=\"token attr-name\">id<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">ID<\/span><span class=\"token operator\">!<\/span>\r\n    <span class=\"token attr-name\">published<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">Boolean<\/span><span class=\"token operator\">!<\/span>\r\n    <span class=\"token attr-name\">title<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">String<\/span><span class=\"token operator\">!<\/span>\r\n    <mark><span class=\"token attr-name\">author<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token class-name\">User<\/span><\/mark>\r\n  <span class=\"token punctuation\">}<\/span>\r\n\r\n  <span class=\"token keyword\">type<\/span> <span class=\"token class-name\">Query<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token attr-name\">feed<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token class-name\">Post<\/span><span class=\"token operator\">!<\/span><span class=\"token punctuation\">]<\/span><span class=\"token operator\">!<\/span>\r\n    <span class=\"token attr-name\">post<\/span><span class=\"token punctuation\">(<\/span><span class=\"token attr-name\">id<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">ID<\/span><span class=\"token operator\">!<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token class-name\">Post<\/span>\r\n  <span class=\"token punctuation\">}<\/span>\r\n\r\n  <span class=\"token keyword\">type<\/span> <span class=\"token class-name\">Mutation<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <mark><span class=\"token attr-name\">createUser<\/span><span class=\"token punctuation\">(<\/span><span class=\"token attr-name\">data<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token atom-input class-name\">UserCreateInput<\/span><span class=\"token operator\">!<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token class-name\">User<\/span><span class=\"token operator\">!<\/span><\/mark>\r\n    <span class=\"token attr-name\">createDraft<\/span><span class=\"token punctuation\">(<\/span><mark><span class=\"token attr-name\">authorEmail<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">String<\/span><span class=\"token punctuation\">,<\/span> <\/mark><span class=\"token attr-name\">content<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">String<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token attr-name\">title<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">String<\/span><span class=\"token operator\">!<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token class-name\">Post<\/span><span class=\"token operator\">!<\/span>\r\n    <span class=\"token attr-name\">publish<\/span><span class=\"token punctuation\">(<\/span><span class=\"token attr-name\">id<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">ID<\/span><span class=\"token operator\">!<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token class-name\">Post<\/span>\r\n  <span class=\"token punctuation\">}<\/span>\r\n\r\n  <mark><span class=\"token keyword\">input<\/span> <span class=\"token atom-input class-name\">UserCreateInput<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n    <mark><span class=\"token attr-name\">email<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">String<\/span><span class=\"token operator\">!<\/span><\/mark>\r\n    <mark><span class=\"token attr-name\">name<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">String<\/span><\/mark>\r\n    <mark><span class=\"token attr-name\">posts<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token atom-input class-name\">PostCreateWithoutAuthorInput<\/span><span class=\"token operator\">!<\/span><span class=\"token punctuation\">]<\/span><\/mark>\r\n  <mark><span class=\"token punctuation\">}<\/span><\/mark>\r\n\r\n  <mark><span class=\"token keyword\">input<\/span> <span class=\"token atom-input class-name\">PostCreateWithoutAuthorInput<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n    <mark><span class=\"token attr-name\">content<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">String<\/span><\/mark>\r\n    <mark><span class=\"token attr-name\">published<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">Boolean<\/span><\/mark>\r\n    <mark><span class=\"token attr-name\">title<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token scalar\">String<\/span><span class=\"token operator\">!<\/span><\/mark>\r\n  <mark><span class=\"token punctuation\">}<\/span><\/mark>\r\n<\/span><span class=\"token template-punctuation string\">`<\/span><\/span>\r\n<span class=\"token operator\">...<\/span>\r\n<\/code><\/pre>\n<p>You incorporate these modifications into the GraphQL schema in this latest version of the code.<\/p>\n<ul class=\"post-ul\">\n<li>The User type, which returns an array of Post.<\/li>\n<li>The author field to the Post type.<\/li>\n<li>The createUser mutation, which expects the UserCreateInput as its input type.<\/li>\n<li>The PostCreateWithoutAuthorInput input type used in the UserCreateInput input for creating posts as part of the createUser mutation.<\/li>\n<li>The authorEmail optional argument to the createDraft mutation.<\/li>\n<\/ul>\n<p>Once the schema has been updated, you can proceed with updating the resolvers to align with the schema.<\/p>\n<p>You should modify the resolvers object by including the highlighted lines in the following manner:<\/p>\n<div>Please provide more context or details about what specifically you want me to paraphrase in the given file.<\/div>\n<pre class=\"post-pre\"><code><span class=\"token operator\">...<\/span>\r\n<span class=\"token keyword\">const<\/span> resolvers <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">{<\/span>\r\n  <span class=\"token literal-property property\">Query<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token function-variable function\">feed<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">parent<span class=\"token punctuation\">,<\/span> args<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> <span class=\"token punctuation\">{<\/span>\r\n      <span class=\"token keyword\">return<\/span> prisma<span class=\"token punctuation\">.<\/span>post<span class=\"token punctuation\">.<\/span><span class=\"token function\">findMany<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span>\r\n        <span class=\"token literal-property property\">where<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token literal-property property\">published<\/span><span class=\"token operator\">:<\/span> <span class=\"token boolean\">true<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n      <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span>\r\n    <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n    <span class=\"token function-variable function\">post<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">parent<span class=\"token punctuation\">,<\/span> args<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> <span class=\"token punctuation\">{<\/span>\r\n      <span class=\"token keyword\">return<\/span> prisma<span class=\"token punctuation\">.<\/span>post<span class=\"token punctuation\">.<\/span><span class=\"token function\">findUnique<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span>\r\n        <span class=\"token literal-property property\">where<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token literal-property property\">id<\/span><span class=\"token operator\">:<\/span> <span class=\"token function\">Number<\/span><span class=\"token punctuation\">(<\/span>args<span class=\"token punctuation\">.<\/span>id<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n      <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span>\r\n    <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n  <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span>\r\n  <mark><span class=\"token literal-property property\">Mutation<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n    <mark><span class=\"token function-variable function\">createDraft<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">parent<span class=\"token punctuation\">,<\/span> args<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n      <mark><span class=\"token keyword\">return<\/span> prisma<span class=\"token punctuation\">.<\/span>post<span class=\"token punctuation\">.<\/span><span class=\"token function\">create<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span><\/mark>\r\n        <mark><span class=\"token literal-property property\">data<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n          <mark><span class=\"token literal-property property\">title<\/span><span class=\"token operator\">:<\/span> args<span class=\"token punctuation\">.<\/span>title<span class=\"token punctuation\">,<\/span><\/mark>\r\n          <mark><span class=\"token literal-property property\">content<\/span><span class=\"token operator\">:<\/span> args<span class=\"token punctuation\">.<\/span>content<span class=\"token punctuation\">,<\/span><\/mark>\r\n          <mark><span class=\"token literal-property property\">published<\/span><span class=\"token operator\">:<\/span> <span class=\"token boolean\">false<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n          <mark><span class=\"token literal-property property\">author<\/span><span class=\"token operator\">:<\/span> args<span class=\"token punctuation\">.<\/span>authorEmail <span class=\"token operator\">&amp;&amp;<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n            <mark><span class=\"token literal-property property\">connect<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token literal-property property\">email<\/span><span class=\"token operator\">:<\/span> args<span class=\"token punctuation\">.<\/span>authorEmail <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n          <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n        <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n      <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><\/mark>\r\n    <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n    <mark><span class=\"token function-variable function\">publish<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">parent<span class=\"token punctuation\">,<\/span> args<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n      <mark><span class=\"token keyword\">return<\/span> prisma<span class=\"token punctuation\">.<\/span>post<span class=\"token punctuation\">.<\/span><span class=\"token function\">update<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span><\/mark>\r\n        <mark><span class=\"token literal-property property\">where<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token literal-property property\">id<\/span><span class=\"token operator\">:<\/span> <span class=\"token function\">Number<\/span><span class=\"token punctuation\">(<\/span>args<span class=\"token punctuation\">.<\/span>id<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n        <mark><span class=\"token literal-property property\">data<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n          <mark><span class=\"token literal-property property\">published<\/span><span class=\"token operator\">:<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n        <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n      <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><\/mark>\r\n    <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n    <mark><span class=\"token function-variable function\">createUser<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">parent<span class=\"token punctuation\">,<\/span> args<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n      <mark><span class=\"token keyword\">return<\/span> prisma<span class=\"token punctuation\">.<\/span>user<span class=\"token punctuation\">.<\/span><span class=\"token function\">create<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span><\/mark>\r\n        <mark><span class=\"token literal-property property\">data<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n          <mark><span class=\"token literal-property property\">email<\/span><span class=\"token operator\">:<\/span> args<span class=\"token punctuation\">.<\/span>data<span class=\"token punctuation\">.<\/span>email<span class=\"token punctuation\">,<\/span><\/mark>\r\n          <mark><span class=\"token literal-property property\">name<\/span><span class=\"token operator\">:<\/span> args<span class=\"token punctuation\">.<\/span>data<span class=\"token punctuation\">.<\/span>name<span class=\"token punctuation\">,<\/span><\/mark>\r\n          <mark><span class=\"token literal-property property\">posts<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n            <mark><span class=\"token literal-property property\">create<\/span><span class=\"token operator\">:<\/span> args<span class=\"token punctuation\">.<\/span>data<span class=\"token punctuation\">.<\/span>posts<span class=\"token punctuation\">,<\/span><\/mark>\r\n          <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n        <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n      <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><\/mark>\r\n    <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n  <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n  <mark><span class=\"token literal-property property\">User<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n    <mark><span class=\"token function-variable function\">posts<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">parent<span class=\"token punctuation\">,<\/span> args<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n      <mark><span class=\"token keyword\">return<\/span> prisma<span class=\"token punctuation\">.<\/span>user<\/mark>\r\n        <span class=\"token punctuation\">.<\/span><mark><span class=\"token function\">findUnique<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span><\/mark>\r\n          <mark><span class=\"token literal-property property\">where<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token literal-property property\">id<\/span><span class=\"token operator\">:<\/span> parent<span class=\"token punctuation\">.<\/span>id <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n        <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><\/mark>\r\n        <span class=\"token punctuation\">.<\/span><mark><span class=\"token function\">posts<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/mark>\r\n    <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n  <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n  <mark><span class=\"token literal-property property\">Post<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n    <mark><span class=\"token function-variable function\">author<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">parent<span class=\"token punctuation\">,<\/span> args<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">=&gt;<\/span> <span class=\"token punctuation\">{<\/span><\/mark>\r\n      <mark><span class=\"token keyword\">return<\/span> prisma<span class=\"token punctuation\">.<\/span>post<\/mark>\r\n        <span class=\"token punctuation\">.<\/span><mark><span class=\"token function\">findUnique<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span><\/mark>\r\n          <mark><span class=\"token literal-property property\">where<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token literal-property property\">id<\/span><span class=\"token operator\">:<\/span> parent<span class=\"token punctuation\">.<\/span>id <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n        <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><\/mark>\r\n        <span class=\"token punctuation\">.<\/span><mark><span class=\"token function\">author<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/mark>\r\n    <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n  <mark><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><\/mark>\r\n<span class=\"token punctuation\">}<\/span>\r\n<span class=\"token operator\">...<\/span>\r\n<\/code><\/pre>\n<p>If the authorEmail argument is provided, the createDraft mutation resolver establishes a connection between the newly created draft and a user already in the system.<\/p>\n<p>The createUser mutation resolver generates a user and its associated posts by employing nested writes.<\/p>\n<p>To resolve the posts and author fields in the User or Post queries, the User.posts and Post.author resolvers are utilizing Prisma&#8217;s Fluent API for fetching the relations.<\/p>\n<p>Please save the file and exit.<\/p>\n<p>Begin the server to check the functionality of the GraphQL API.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">npm<\/span> start<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Start by trying out the createUser resolver using the given GraphQL mutation.<\/p>\n<pre class=\"post-pre\"><code><span class=\"token keyword\">mutation<\/span> <span class=\"token punctuation\">{<\/span>\r\n  <span class=\"token property-query property-mutation\">createUser<\/span><span class=\"token punctuation\">(<\/span><span class=\"token attr-name\">data<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token attr-name\">email<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">\"natalia@prisma.io\"<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token attr-name\">name<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">\"Natalia\"<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token property\">email<\/span>\r\n    <span class=\"token property\">id<\/span>\r\n  <span class=\"token punctuation\">}<\/span>\r\n<span class=\"token punctuation\">}<\/span>\r\n<\/code><\/pre>\n<p>This genetic alteration will generate a new individual.<\/p>\n<p>Afterwards, try out the createDraft resolver by using the specified mutation.<\/p>\n<pre class=\"post-pre\"><code><span class=\"token keyword\">mutation<\/span> <span class=\"token punctuation\">{<\/span>\r\n  <span class=\"token property-query property-mutation\">createDraft<\/span><span class=\"token punctuation\">(<\/span>\r\n    <span class=\"token attr-name\">authorEmail<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token description string\">\"<span class=\"token language-markdown\">natalia@prisma.io<\/span>\"<\/span>\r\n    <span class=\"token attr-name\">title<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">\"Deploying a GraphQL API to App Platform\"<\/span>\r\n  <span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token property\">id<\/span>\r\n    <span class=\"token property\">title<\/span>\r\n    <span class=\"token property\">content<\/span>\r\n    <span class=\"token property\">published<\/span>\r\n    <span class=\"token object\">author<\/span> <span class=\"token punctuation\">{<\/span>\r\n      <span class=\"token property\">id<\/span>\r\n      <span class=\"token property\">name<\/span>\r\n    <span class=\"token punctuation\">}<\/span>\r\n  <span class=\"token punctuation\">}<\/span>\r\n<span class=\"token punctuation\">}<\/span>\r\n<\/code><\/pre>\n<p>If the query&#8217;s return value is a Post, you have the ability to retrieve the author. The Post.author resolver will be invoked in this scenario.<\/p>\n<p>When you are done with the testing, please close the server.<\/p>\n<p>Afterward, finalize your modifications and upload them to implement the API.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">git<\/span> <span class=\"token function\">add<\/span> <span class=\"token builtin class-name\">.<\/span><\/li>\n<li data-prefix=\"$\"><span class=\"token function\">git<\/span> commit <span class=\"token parameter variable\">-m<\/span> <span class=\"token string\">&#8220;add user model&#8221;<\/span><\/li>\n<li data-prefix=\"$\"><span class=\"token function\">git<\/span> push<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Your updates may take a few minutes to be deployed.<\/p>\n<p>You have effectively upgraded your database schema using Prisma Migrate and made the new model accessible in your GraphQL API.<\/p>\n<h2>In summary, to conclude.<\/h2>\n<p>In this article, we developed a GraphQL API using Prisma and deployed it on Silicon Cloud\u2019s App Platform. We created a GraphQL schema and resolvers using Apollo Server. In these resolvers, we utilized Prisma Client to store and retrieve data in the PostgreSQL database. For further improvement, we can enhance the GraphQL API by adding a query to fetch individual users and a mutation to link an existing draft to a user.<\/p>\n<p>If you want to delve into the data stored in the database, Prisma Studio is worth checking out. Additionally, you can refer to the Prisma documentation to gain insights into various aspects of Prisma and explore pre-built example projects in the prisma-examples repository.<\/p>\n<p>The code for this project is available in the Silicon Cloud Community repository.<\/p>\n<p>&nbsp;<\/p>\n<p>More Tutorials<\/p>\n<p><a class=\"LinkSuggestion__Link-sc-1gewdgc-4 cLBplk\" href=\"https:\/\/www.silicloud.com\/blog\/the-main-method-in-java-is-declared-as-public-static-void-mainstring-args\/\" target=\"_blank\" rel=\"noopener\">The main method in Java<span class=\"sc-gswNZR eASTkv\">(Opens in a new browser tab)<\/span><\/a><\/p>\n<p><a class=\"LinkSuggestion__Link-sc-1gewdgc-4 cLBplk\" href=\"https:\/\/www.silicloud.com\/blog\/jquery-tree-traversal-functions\/\" target=\"_blank\" rel=\"noopener\">jQuery parent() and children() tree traversal functions<span class=\"sc-gswNZR eASTkv\">(Opens in a new browser tab)<\/span><\/a><\/p>\n<p><a class=\"LinkSuggestion__Link-sc-1gewdgc-4 cLBplk\" href=\"https:\/\/www.silicloud.com\/blog\/python-http-client-request-get-post-using-python-for-making-http-client-requests-such-as-get-and-post-methods\/\" target=\"_blank\" rel=\"noopener\">Python HTTP requests such as GET and POST methods.<span class=\"sc-gswNZR eASTkv\">(Opens in a new browser tab)<\/span><\/a><\/p>\n<p><a class=\"LinkSuggestion__Link-sc-1gewdgc-4 cLBplk\" href=\"https:\/\/www.silicloud.com\/blog\/tutorials-on-java-ee\/\" target=\"_blank\" rel=\"noopener\">Tutorials on Java EE<span class=\"sc-gswNZR eASTkv\">(Opens in a new browser tab)<\/span><\/a><\/p>\n<p><a class=\"LinkSuggestion__Link-sc-1gewdgc-4 cLBplk\" href=\"https:\/\/www.silicloud.com\/blog\/how-to-integrate-playwright-for-react-application-component-testing\/\" target=\"_blank\" rel=\"noopener\">React Application Component Testing Integrate with Playwright<span class=\"sc-gswNZR eASTkv\">(Opens in a new browser tab)<\/span><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As part of the Write for Donations program, the authors opted to donate to the COVID-19 Relief Fund and the Tech Education Fund. To begin with, GraphQL is an API query language that includes a language for defining the structure of an API, as well as a language for querying data from the API. It [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-1050","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Creating a GraphQL API using Prisma on Silicon Cloud&#039;s App Platform - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"GraphQL is an API query language that includes a language for defining the structure of an API, as well as a language for querying data from\" \/>\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.silicloud.com\/blog\/creating-a-graphql-api-using-prisma-on-silicon-clouds-app-platform\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Creating a GraphQL API using Prisma on Silicon Cloud&#039;s App Platform\" \/>\n<meta property=\"og:description\" content=\"GraphQL is an API query language that includes a language for defining the structure of an API, as well as a language for querying data from\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/blog\/creating-a-graphql-api-using-prisma-on-silicon-clouds-app-platform\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/SiliCloudGlobal\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-02-20T15:56:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-14T15:28:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/655c6abdc40ba52feef1d6e8\/83-0.png\" \/>\n<meta name=\"author\" content=\"Emily Johnson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@SiliCloudGlobal\" \/>\n<meta name=\"twitter:site\" content=\"@SiliCloudGlobal\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Emily Johnson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"32 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/creating-a-graphql-api-using-prisma-on-silicon-clouds-app-platform\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/creating-a-graphql-api-using-prisma-on-silicon-clouds-app-platform\/\"},\"author\":{\"name\":\"Emily Johnson\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/3b041b19cffc258705478ecfab895378\"},\"headline\":\"Creating a GraphQL API using Prisma on Silicon Cloud&#8217;s App Platform\",\"datePublished\":\"2023-02-20T15:56:49+00:00\",\"dateModified\":\"2024-03-14T15:28:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/creating-a-graphql-api-using-prisma-on-silicon-clouds-app-platform\/\"},\"wordCount\":6646,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\"},\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/creating-a-graphql-api-using-prisma-on-silicon-clouds-app-platform\/\",\"url\":\"https:\/\/www.silicloud.com\/blog\/creating-a-graphql-api-using-prisma-on-silicon-clouds-app-platform\/\",\"name\":\"Creating a GraphQL API using Prisma on Silicon Cloud's App Platform - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#website\"},\"datePublished\":\"2023-02-20T15:56:49+00:00\",\"dateModified\":\"2024-03-14T15:28:44+00:00\",\"description\":\"GraphQL is an API query language that includes a language for defining the structure of an API, as well as a language for querying data from\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/creating-a-graphql-api-using-prisma-on-silicon-clouds-app-platform\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/blog\/creating-a-graphql-api-using-prisma-on-silicon-clouds-app-platform\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/creating-a-graphql-api-using-prisma-on-silicon-clouds-app-platform\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.silicloud.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Creating a GraphQL API using Prisma on Silicon Cloud&#8217;s App Platform\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/blog\/\",\"name\":\"Silicon Cloud Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\",\"name\":\"Silicon Cloud Blog\",\"url\":\"https:\/\/www.silicloud.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png\",\"contentUrl\":\"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png\",\"width\":1024,\"height\":1024,\"caption\":\"Silicon Cloud Blog\"},\"image\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/SiliCloudGlobal\/\",\"https:\/\/twitter.com\/SiliCloudGlobal\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/3b041b19cffc258705478ecfab895378\",\"name\":\"Emily Johnson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/a5cb4e73d02ab1d79f2dfe919389ff7c1de072baa97686392031c03d858cc358?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/a5cb4e73d02ab1d79f2dfe919389ff7c1de072baa97686392031c03d858cc358?s=96&d=mm&r=g\",\"caption\":\"Emily Johnson\"},\"url\":\"https:\/\/www.silicloud.com\/blog\/author\/emilyjohnson\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Creating a GraphQL API using Prisma on Silicon Cloud's App Platform - Blog - Silicon Cloud","description":"GraphQL is an API query language that includes a language for defining the structure of an API, as well as a language for querying data from","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.silicloud.com\/blog\/creating-a-graphql-api-using-prisma-on-silicon-clouds-app-platform\/","og_locale":"en_US","og_type":"article","og_title":"Creating a GraphQL API using Prisma on Silicon Cloud's App Platform","og_description":"GraphQL is an API query language that includes a language for defining the structure of an API, as well as a language for querying data from","og_url":"https:\/\/www.silicloud.com\/blog\/creating-a-graphql-api-using-prisma-on-silicon-clouds-app-platform\/","og_site_name":"Blog - Silicon Cloud","article_publisher":"https:\/\/www.facebook.com\/SiliCloudGlobal\/","article_published_time":"2023-02-20T15:56:49+00:00","article_modified_time":"2024-03-14T15:28:44+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/655c6abdc40ba52feef1d6e8\/83-0.png"}],"author":"Emily Johnson","twitter_card":"summary_large_image","twitter_creator":"@SiliCloudGlobal","twitter_site":"@SiliCloudGlobal","twitter_misc":{"Written by":"Emily Johnson","Est. reading time":"32 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.silicloud.com\/blog\/creating-a-graphql-api-using-prisma-on-silicon-clouds-app-platform\/#article","isPartOf":{"@id":"https:\/\/www.silicloud.com\/blog\/creating-a-graphql-api-using-prisma-on-silicon-clouds-app-platform\/"},"author":{"name":"Emily Johnson","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/3b041b19cffc258705478ecfab895378"},"headline":"Creating a GraphQL API using Prisma on Silicon Cloud&#8217;s App Platform","datePublished":"2023-02-20T15:56:49+00:00","dateModified":"2024-03-14T15:28:44+00:00","mainEntityOfPage":{"@id":"https:\/\/www.silicloud.com\/blog\/creating-a-graphql-api-using-prisma-on-silicon-clouds-app-platform\/"},"wordCount":6646,"commentCount":0,"publisher":{"@id":"https:\/\/www.silicloud.com\/blog\/#organization"},"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/blog\/creating-a-graphql-api-using-prisma-on-silicon-clouds-app-platform\/","url":"https:\/\/www.silicloud.com\/blog\/creating-a-graphql-api-using-prisma-on-silicon-clouds-app-platform\/","name":"Creating a GraphQL API using Prisma on Silicon Cloud's App Platform - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/blog\/#website"},"datePublished":"2023-02-20T15:56:49+00:00","dateModified":"2024-03-14T15:28:44+00:00","description":"GraphQL is an API query language that includes a language for defining the structure of an API, as well as a language for querying data from","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/blog\/creating-a-graphql-api-using-prisma-on-silicon-clouds-app-platform\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/blog\/creating-a-graphql-api-using-prisma-on-silicon-clouds-app-platform\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/blog\/creating-a-graphql-api-using-prisma-on-silicon-clouds-app-platform\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.silicloud.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Creating a GraphQL API using Prisma on Silicon Cloud&#8217;s App Platform"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/blog\/#website","url":"https:\/\/www.silicloud.com\/blog\/","name":"Silicon Cloud Blog","description":"","publisher":{"@id":"https:\/\/www.silicloud.com\/blog\/#organization"},"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.silicloud.com\/blog\/#organization","name":"Silicon Cloud Blog","url":"https:\/\/www.silicloud.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png","contentUrl":"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png","width":1024,"height":1024,"caption":"Silicon Cloud Blog"},"image":{"@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/SiliCloudGlobal\/","https:\/\/twitter.com\/SiliCloudGlobal"]},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/3b041b19cffc258705478ecfab895378","name":"Emily Johnson","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/a5cb4e73d02ab1d79f2dfe919389ff7c1de072baa97686392031c03d858cc358?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a5cb4e73d02ab1d79f2dfe919389ff7c1de072baa97686392031c03d858cc358?s=96&d=mm&r=g","caption":"Emily Johnson"},"url":"https:\/\/www.silicloud.com\/blog\/author\/emilyjohnson\/"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/1050","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/comments?post=1050"}],"version-history":[{"count":0,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/1050\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/media?parent=1050"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/categories?post=1050"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/tags?post=1050"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}