<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: MANOJ AP</title>
    <description>The latest articles on DEV Community by MANOJ AP (@manojap).</description>
    <link>https://dev.to/manojap</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F441448%2Ff5fd1932-5cea-47c7-b566-43be16aaf4b2.jpeg</url>
      <title>DEV Community: MANOJ AP</title>
      <link>https://dev.to/manojap</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/manojap"/>
    <language>en</language>
    <item>
      <title>Parallels and MSSQL Server</title>
      <dc:creator>MANOJ AP</dc:creator>
      <pubDate>Thu, 28 Sep 2023 04:48:38 +0000</pubDate>
      <link>https://dev.to/manojap/parallels-and-mssql-server-2j6a</link>
      <guid>https://dev.to/manojap/parallels-and-mssql-server-2j6a</guid>
      <description>&lt;p&gt;I recently purchased a Mac-Mini-M2 (Base Model), it was awesome and fast enough to kill my Windows 11 Laptop , :). Since I am supposed to develop Mac and Windows, also looking for a VM which utilise the power of M2 Silicon. &lt;/p&gt;

&lt;h2&gt;
  
  
  Development setup on Parallels
&lt;/h2&gt;

&lt;p&gt;Firstly I installed Microsoft Visual Studio ,and it work better than ** ASUS Laptop with 8 GB Intel Core i5**&lt;/p&gt;

&lt;p&gt;Also need a Microsoft SQL Server for backend needs and I started the install the setup, it just went with errors. &lt;/p&gt;

&lt;h2&gt;
  
  
  Docker
&lt;/h2&gt;

&lt;p&gt;The second option for me is Docker on the Parallel. I tried and it succesfulluy installed. But the engine doesn't work for me. I google it, since it is container it is not possible.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Docker Solution
&lt;/h2&gt;

&lt;p&gt;Docker container on Mac OS - That will be work right. Note that Some of the Docker Images (most) were built for Intel M1 chip. In such cases need to install Rosetta first, which help the transition of Intel to silicone.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;softwareupdate--install--rosetta&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How do I connect Mac Docker to Parallel Visual Studio ?
&lt;/h2&gt;

&lt;p&gt;We can simply use the Mac IP with container exposed port as bellow. Go to Network click the Network option to get the IP.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 &amp;lt;add name="Dolphin_Accounts.Properties.Settings.sql_connection" connectionString="Data Source=192.168.20.101,1433;Password=mssql1Ipw;User Id=sa;Initial Catalog=dolphinedb;Integrated Security=False" /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Docker Compose iml
&lt;/h2&gt;

&lt;p&gt;`version: '3.9'&lt;/p&gt;

&lt;p&gt;services:&lt;br&gt;
  mssql-azur-edge2:&lt;br&gt;
    image: mcr.microsoft.com/azure-sql-edge&lt;br&gt;
    platform: linux/arm64&lt;br&gt;
    ports:&lt;br&gt;
      - 1433:1433&lt;br&gt;&lt;br&gt;
    volumes:&lt;br&gt;
      - ~/apps/mssql/data:/var/lib/mssqlql/data&lt;br&gt;
    environment:&lt;br&gt;
      - ACCEPT_EULA=Y&lt;br&gt;
      - SA_PASSWORD=mssql1Ipw&lt;/p&gt;

&lt;p&gt;From the terminal run &lt;code&gt;docker-compose up -d&lt;/code&gt; and also make sure it is running by issuing the &lt;code&gt;docker-compose ps&lt;/code&gt; command.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://devmnj.wordpress.com"&gt;More post on M2,Docker and Mac-Mini-M2 setup  &lt;/a&gt;&lt;/p&gt;

</description>
      <category>macmini</category>
      <category>m2</category>
      <category>programming</category>
      <category>sql</category>
    </item>
    <item>
      <title>React client error</title>
      <dc:creator>MANOJ AP</dc:creator>
      <pubDate>Tue, 31 May 2022 05:32:02 +0000</pubDate>
      <link>https://dev.to/manojap/react-client-error-5821</link>
      <guid>https://dev.to/manojap/react-client-error-5821</guid>
      <description>&lt;p&gt;When I work with &lt;strong&gt;react-quill&lt;/strong&gt; and &lt;strong&gt;react-editor-js&lt;/strong&gt; I got either a double instance or an error which shows &lt;em&gt;react-dom/client error&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;I fix problem by using render method. The two of the cases caused by the same.&lt;/p&gt;

&lt;h2&gt;
  
  
  Editorjs
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xmg8grfW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tsvx82iyrydswrg3n8ma.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xmg8grfW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tsvx82iyrydswrg3n8ma.png" alt="Image description" width="424" height="915"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Quilljs
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cDa8ybDF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qk77farv5g41qzeo58nb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cDa8ybDF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qk77farv5g41qzeo58nb.png" alt="Image description" width="800" height="273"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  index.js
&lt;/h2&gt;

&lt;p&gt;`import React from 'react';&lt;br&gt;
import ReactDOM from 'react-dom/client';&lt;br&gt;
import './index.css';&lt;br&gt;
import App from './App';&lt;br&gt;
import reportWebVitals from './reportWebVitals';&lt;/p&gt;

&lt;p&gt;const root = ReactDOM.createRoot(document.getElementById('root'));&lt;br&gt;
root.render(&lt;br&gt;
  &lt;br&gt;
    &lt;br&gt;
  &lt;br&gt;
);&lt;/p&gt;

&lt;p&gt;// If you want to start measuring performance in your app, pass a function&lt;br&gt;
// to log results (for example: reportWebVitals(console.log))&lt;br&gt;
// or send to an analytics endpoint. Learn more: &lt;a href="https://bit.ly/CRA-vitals"&gt;https://bit.ly/CRA-vitals&lt;/a&gt;&lt;br&gt;
reportWebVitals();`&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix worked for me.
&lt;/h2&gt;

&lt;p&gt;import ReactDOM from "react-dom";&lt;br&gt;
import React from "react";&lt;br&gt;
// import { createRoot } from "react-dom/client";&lt;/p&gt;

&lt;p&gt;import App from "./App";&lt;/p&gt;

&lt;p&gt;const rootElement = document.getElementById("root");&lt;br&gt;
// const root = createRoot(rootElement);&lt;br&gt;
ReactDOM.render(, rootElement);&lt;/p&gt;

&lt;p&gt;My question is that, why this happening ?&lt;/p&gt;

&lt;p&gt;More thoughts on &lt;a href="https://devmnj.blogspot.com"&gt;JSU&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Cross-thread operation not valid fix - C# back ground worker</title>
      <dc:creator>MANOJ AP</dc:creator>
      <pubDate>Tue, 12 Apr 2022 12:10:12 +0000</pubDate>
      <link>https://dev.to/manojap/cross-thread-operation-not-valid-fix-c-back-ground-worker-2god</link>
      <guid>https://dev.to/manojap/cross-thread-operation-not-valid-fix-c-back-ground-worker-2god</guid>
      <description>&lt;h2&gt;
  
  
  How to fix
&lt;/h2&gt;

&lt;p&gt;When you try to access a component in the UI from a Background Worker DoWork event in C#.net, may end up like this.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;System.InvalidOperationException: 'Cross-thread operation not valid: Control 'listView1' accessed from a thread other than the thread it was created on...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;To bypass this error C#.Net  provides *&lt;em&gt;invoke  *&lt;/em&gt; method which execute the **delegate **specified. &lt;/p&gt;

&lt;p&gt;Invoke let us directly interact from other threads. &lt;/p&gt;

&lt;p&gt;To add items to a listview from a  background  worker I used the following code snippet which uses a  *&lt;em&gt;MethodInvoker  **and a  **delegate *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;listView1.Invoke(new MethodInvoker(delegate&lt;br&gt;
                                 {&lt;br&gt;
                                     item = new ListViewItem("");&lt;br&gt;
                                     item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "Some Column Value Here"));                                       &lt;br&gt;
                                     listView1.Items.Add(item);&lt;br&gt;
                                 }&lt;br&gt;
                                 ));&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here is some guides that can save your time &lt;a href="http://devmnj.wordpress.com/tag/c#"&gt;how to&lt;/a&gt; , &lt;a href="https://devmnj.blogspot.com"&gt;snippets-various&lt;/a&gt;&lt;/p&gt;

</description>
      <category>backgroundworker</category>
      <category>csharp</category>
      <category>winform</category>
    </item>
    <item>
      <title>How to Containerize Golang app with Docker</title>
      <dc:creator>MANOJ AP</dc:creator>
      <pubDate>Sat, 26 Feb 2022 04:08:22 +0000</pubDate>
      <link>https://dev.to/manojap/how-to-containerize-golang-app-with-docker-251a</link>
      <guid>https://dev.to/manojap/how-to-containerize-golang-app-with-docker-251a</guid>
      <description>&lt;p&gt;To containerize a Golang app is similar to any other project. We need to use the base image for golandg and build the app.&lt;/p&gt;

&lt;p&gt;Install Docker desktop , if you are on windows and create an account first. Then in the project create Dockerfile ( no extension required) with following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM  golang:1.18beta2-bullseye
RUN mkdir /app
ADD . /app
WORKDIR /app
RUN go build -o main .
CMD ["/app/main"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Save the file in root of the project&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Building the Docker Image
&lt;/h2&gt;

&lt;p&gt;Go to the terminal and CD into the project folder and build the image. Docker image can be used to run different process.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker build -t my-go-app . 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;try to list image using docker images command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker images 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Using the image
&lt;/h2&gt;

&lt;p&gt;To use the image we created with run command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -d -p 8080:8080 --name test1 my-go-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above command will run the image in detached mode, leaving console reedy for another execution.&lt;/p&gt;

&lt;p&gt;It also exposed to port internal 8080:8080. Go to the browser and try localhost:8080 and it should have working.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stopping, Starting and removing containers
&lt;/h2&gt;

&lt;p&gt;Using &lt;code&gt;docker stop &amp;lt;container-name/id&amp;gt;&lt;/code&gt;. Once it stopped can delete using &lt;code&gt;docker rm container-name/id&lt;/code&gt; command.&lt;/p&gt;

&lt;p&gt;Need to start again ? use the &lt;code&gt;docker start&lt;/code&gt; command. &lt;/p&gt;

&lt;p&gt;Wanna know running processes/ containers ? Try &lt;code&gt;docker ps&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Here is more guides on &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://devmnj.wordpress.com/tag/golang/"&gt;Golang&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://devmnj.wordpress.com/tag/docker/"&gt;Docker&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>go</category>
      <category>docker</category>
    </item>
    <item>
      <title>GCC erron Golang</title>
      <dc:creator>MANOJ AP</dc:creator>
      <pubDate>Wed, 09 Feb 2022 03:55:47 +0000</pubDate>
      <link>https://dev.to/manojap/gcc-erron-golang-4cgi</link>
      <guid>https://dev.to/manojap/gcc-erron-golang-4cgi</guid>
      <description>&lt;p&gt;On windows you may got the gcc compiler error while trying to add packages like "gorm.io/driver/sqlite" in Golang. The cause for the error is that, underlying package require the gcc C compiler which is not installed on Windows PC by default.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;We need to install the C compiler (gcc) on Windows machine and also need to add the path to environment variable.&lt;/p&gt;

&lt;p&gt;The easiest way to install the &lt;a href="https://jmeubank.github.io/tdm-gcc/"&gt;mingw&lt;/a&gt;, is get package from tmd-gcc repository.&lt;/p&gt;

&lt;p&gt;Also add the path to the bin folder as follows, in environment variables. (Just type &lt;code&gt;env&lt;/code&gt; on start menu and you will get environment variables dialog)&lt;/p&gt;

&lt;p&gt;&lt;code&gt;C:\TDM-GCC-64\bin&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Read More Golang guides on &lt;a href="https://devmnj.wordpress.com/tag/golang"&gt;JSU&lt;/a&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>how</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Flutter listview crashes in Column widget</title>
      <dc:creator>MANOJ AP</dc:creator>
      <pubDate>Tue, 18 Jan 2022 03:41:07 +0000</pubDate>
      <link>https://dev.to/manojap/flutter-listview-crashes-in-column-widget-595g</link>
      <guid>https://dev.to/manojap/flutter-listview-crashes-in-column-widget-595g</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yGYnvZ4---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qod12tkz6loah9ayfn5l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yGYnvZ4---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qod12tkz6loah9ayfn5l.png" alt="Flutter" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Listview and Column Widget
&lt;/h2&gt;

&lt;p&gt;Sometimes you may want to combine UI vertically along the screen, that’s were we need a Column Widget.&lt;/p&gt;

&lt;p&gt;When I tried to place a search box, a customized Text widget, and ListView widget, Flutter shower with errors.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Column(&lt;br&gt;
         children: [&lt;br&gt;
           SearchBox(hintText: 'Search', controller: textController),&lt;br&gt;
           ListView.builder(&lt;br&gt;
               // the number of items in the list&lt;br&gt;
               itemCount: adList.length,&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This happens because in the column widget Listview didn’t fit. To make it adjustable for the column wrap the ListView with Expanded widget, in case of Vertical listview.&lt;/p&gt;

&lt;p&gt;The expanded widget can have single child widget.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Column(&lt;br&gt;
          children: [&lt;br&gt;
            SearchBox(hintText: 'Search', controller: textController),&lt;br&gt;
            Expanded(&lt;br&gt;
              child: ListView.builder(&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and it should solve the issue.&lt;/p&gt;

&lt;p&gt;Following Flutter posts deserve a good read&lt;/p&gt;

&lt;p&gt;&lt;a href="https://devmnj.wordpress.com/2020/12/23/how-to-add-web-desktop-support-for-existing-flutter-app-in-opensuse/"&gt;Flutter Desktop Support - OpenSuse&lt;/a&gt;&lt;br&gt;
 &lt;a href="https://devmnj.wordpress.com/2020/11/24/enable-flutter-web-support-on-windows/"&gt;Flutter support for Windows&lt;/a&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
    </item>
    <item>
      <title>Easiest way to handle multiple styles in Reactjs</title>
      <dc:creator>MANOJ AP</dc:creator>
      <pubDate>Tue, 18 Jan 2022 03:33:34 +0000</pubDate>
      <link>https://dev.to/manojap/easiest-way-to-handle-multiple-styles-in-reactjs-5d11</link>
      <guid>https://dev.to/manojap/easiest-way-to-handle-multiple-styles-in-reactjs-5d11</guid>
      <description>&lt;h2&gt;
  
  
  Reactjs
&lt;/h2&gt;

&lt;p&gt;Reactjs is a frontend UI library for developing sophisticated web/native applications using Typescript/Javascript. The library is backed by Facebook and opensource community. For me it is like having a swiss knife in my tool kit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Multiple Styles
&lt;/h2&gt;

&lt;p&gt;For beginners handling styles in React components could difficult. When it came to styles with hyphen (back-style) we have to rely on array syntax.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;div className={styles['back-style']}&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;So what about multiple styles ? We can use the array syntax or use the classNames package (multiple use of className property is not allowed in Reactjs as Vue 3 )&lt;/p&gt;

&lt;p&gt;Let’s use the package&lt;/p&gt;

&lt;p&gt;&lt;code&gt;yarn add classnames&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In the template / HTML use the classNames function to include multiple style classes.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;import classNames from 'classNames'&lt;br&gt;
&amp;lt;div className={classNames('font-style','back-style','container')}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That’s all you need to know.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://devmnj.wordpress.com/tag/reactjs/"&gt;Read more guides on reactjs&lt;/a&gt; &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Create Mui Dark Mode switch using React Context</title>
      <dc:creator>MANOJ AP</dc:creator>
      <pubDate>Sun, 05 Dec 2021 04:48:11 +0000</pubDate>
      <link>https://dev.to/manojap/create-mui-dark-mode-switch-using-react-context-313j</link>
      <guid>https://dev.to/manojap/create-mui-dark-mode-switch-using-react-context-313j</guid>
      <description>&lt;p&gt;Material UI or &lt;a href="https://devmnj.wordpress.com/tag/mui/"&gt;MUI&lt;/a&gt; is one word for all UI needs in Reactjs. It is well documented and easy to use. I really enjoyed it.&lt;br&gt;
In this post I would like to demonstrate how to create dark-mode switcher using the React Context and Material UI switch component.&lt;/p&gt;
&lt;h2&gt;
  
  
  Context
&lt;/h2&gt;

&lt;p&gt;please use &lt;a href="https://devmnj.wordpress.com/tag/dynamic-context/"&gt;these posts&lt;/a&gt; to learn more about Context and the basic step required.&lt;/p&gt;

&lt;p&gt;Our context setup with look like the following&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//context/themeContext.js
 import React from 'react';

export const ThemeContext = React.createContext({
    theme: 'dark',
    setTheme: () =&amp;gt; { }
  })


 //app.js or _app.js

import React, { useState } from 'react'; 
import { ThemeContext } from '../context/themeContext';


function MyApp({ Component, pageProps }) {
  const [theme, setTheme] = useState("light")
  const value = { theme, setTheme };


  return (

      &amp;lt;ThemeContext.Provider value={value}   &amp;gt;
        &amp;lt;Component {...pageProps} /&amp;gt;
      &amp;lt;/ThemeContext.Provider&amp;gt;

  );
}
```


## Theme Switcher 

A MUI customized switch can be used to create a theme switcher. We also need to access the context using the useContext hook. The code will look like the following. 

&amp;gt; The complete switch snippet can be obtained from [Material UI switch documentation page](https://mui.com/components/switches/).



```
import * as React from 'react';
import clsx from 'clsx';
import { styled } from '@mui/system';
import { useSwitch } from '@mui/core/SwitchUnstyled';
import { Tooltip } from '@mui/material';
import { ThemeContext } from '../context/themeContext';
 ...
function MUISwitch(props) {
  const { theme, setTheme } = React.useContext(ThemeContext)
  const { getInputProps, checked, disabled, focusVisible } = useSwitch(props);
  const stateClasses = {
    checked,
    disabled,
    focusVisible,
  };
  var mode = {

  };


  React.useEffect(() =&amp;gt; {
    const mode = stateClasses.checked ? 'dark' : 'light'
    setTheme(mode)
  }, [stateClasses])
  return (
    &amp;lt;Tooltip title="Theme switcher"&amp;gt;
      &amp;lt;SwitchRoot className={clsx(stateClasses)} &amp;gt;
        &amp;lt;SwitchTrack&amp;gt;
          &amp;lt;SwitchThumb className={clsx(stateClasses)} /&amp;gt;
        &amp;lt;/SwitchTrack&amp;gt;
        &amp;lt;SwitchInput {...getInputProps()} aria-label="Demo switch" /&amp;gt;
      &amp;lt;/SwitchRoot&amp;gt;
    &amp;lt;/Tooltip&amp;gt;

  );
}

export default function UseSwitchesCustom() {
  return &amp;lt;MUISwitch defaultChecked /&amp;gt;;
}
```



## Tracking changes

In order observe changes in state of the switch component , we can use useEffect and the **stateClass**. Note that there is no event handler attached to the component.

## Implement the Theme

The theme can be implemented as you wish, one of the suggested way is to create a component to implement the theme and wrap other components inside it. Such a component can be .



```
import React from 'react'
import { createTheme, ThemeProvider, styled } from '@mui/material/styles';
import { ThemeContext } from '../context/themeContext';

export default function BaseTheme(props) {
    const { theme, setTheme } = React.useContext(ThemeContext)
    const theme1 = createTheme(
        {
            palette:
                { mode: theme }
        }
    );

    console.log('Current Theme - ' + JSON.stringify(theme));
    return (
        &amp;lt;div&amp;gt;
            &amp;lt;ThemeProvider theme={theme1} &amp;gt;
                {props.children}
            &amp;lt;/ThemeProvider&amp;gt;
        &amp;lt;/div&amp;gt;
    )
}
```



Read more react posts [On My blog](https://devguides.vercel.app) 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>react</category>
      <category>mui</category>
    </item>
    <item>
      <title>Setup Pinia in Nuxt 3</title>
      <dc:creator>MANOJ AP</dc:creator>
      <pubDate>Sun, 28 Nov 2021 06:22:51 +0000</pubDate>
      <link>https://dev.to/manojap/setup-pinia-in-nuxt-3-37ia</link>
      <guid>https://dev.to/manojap/setup-pinia-in-nuxt-3-37ia</guid>
      <description>&lt;p&gt;May be you are already learned about global state and the Vuex store in Vue and Nuxt projects. Is there any other store for Vue3. Yes, Pinia&lt;/p&gt;

&lt;p&gt;A minimal app is required to try Pinia store, let's create a nuxt3 app. &lt;/p&gt;

&lt;h2&gt;
  
  
  Setup Pinia store in a Nuxt3 app
&lt;/h2&gt;

&lt;p&gt;A minimal app is required to try Pinia store, let's create a nuxt3 app.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx nuxi init nuxt3-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To setup Pinia store add the Nuxt build module configuration, in nuxt-config, may be the yarn installation will already add it for you,lol.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add pinia @pinia/nuxt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The nuxt config will look like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// nuxt.config.js
export default {
  // ... other options
  buildModules: [
    '@pinia/nuxt',
  ],
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Create the store
&lt;/h2&gt;

&lt;p&gt;Go ahead and create store.ts in the src folder. Pinia uses same philosophy of Vuex, the official Vue  store.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//store.ts
import { defineStore, acceptHMRUpdate} from 'pinia'

export const useStore = defineStore('storeId', {
  // arrow function recommended for full type inference
  state: () =&amp;gt; {
    return {
      // all these properties will have their type inferred automatically
      counter: 10,
      name: 'Eduardo',
      isAdmin: true,
    }
  },
  actions:{
     hit(){
       this.counter++;
     }
  },

  getters:{
    getCount:(state)=&amp;gt;state.counter,
    getUser: (state)=&amp;gt; {
      state.name
    }
  }
})

if (import.meta.hot) {
  import.meta.hot.accept(acceptHMRUpdate(useStore, import.meta.hot))
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Accessing the state
&lt;/h3&gt;

&lt;p&gt;Accessing the state / getters / actions in a component by using the useStore. Sorry about mutation they are gone for ever.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//in some component
&amp;lt;script&amp;gt;
import { useStore } from '@/store'
export default {  
  data() {
    return {
      store: useStore()
    }
  },
}
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the template we can use the reactive store to access actions/ getter/ state.&lt;/p&gt;

&lt;h3&gt;
  
  
  State
&lt;/h3&gt;

&lt;p&gt;A single state can be accessed as follows&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;template&amp;gt;   
   &amp;lt;div&amp;gt;
    {{store.name}}
......
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
`&lt;/p&gt;

&lt;h3&gt;
  
  
  Getters
&lt;/h3&gt;

&lt;p&gt;Getters are functions which return the read only state for stores, which can be also accessed with store object and insert in template with my favorite double mustache.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&amp;lt;template&amp;gt;  &lt;br&gt;
{{store.getCount}}&lt;br&gt;
......&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Actions
&lt;/h3&gt;

&lt;p&gt;Actions are for making something happen, like increasing a count, or validating a user etc.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&amp;lt;v-btn @click="store.hit()"&amp;gt;Hit me&amp;lt;/v-btn&amp;gt;&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Read more &lt;a href="https://devguides.vercel.app"&gt;Nuxt3 guides&lt;/a&gt;&lt;/p&gt;

</description>
      <category>nuxt3</category>
      <category>javascript</category>
      <category>pinia</category>
      <category>node</category>
    </item>
    <item>
      <title>Placing text box in WPF DataGrid manually</title>
      <dc:creator>MANOJ AP</dc:creator>
      <pubDate>Fri, 13 Aug 2021 04:55:37 +0000</pubDate>
      <link>https://dev.to/manojap/placing-text-box-in-wpf-datagrid-manually-27ng</link>
      <guid>https://dev.to/manojap/placing-text-box-in-wpf-datagrid-manually-27ng</guid>
      <description>&lt;p&gt;I want to build a sales order form, where customer enter order details. Need to enter rows. wanna place boxes manually on the grid, which move to the row I clicked. I don't want the built in columns&lt;/p&gt;

&lt;p&gt;Any body have an advice ?&lt;/p&gt;

</description>
      <category>wpf</category>
      <category>datagrid</category>
    </item>
    <item>
      <title>How to handle Slatejs document in Nxut-Keystone5</title>
      <dc:creator>MANOJ AP</dc:creator>
      <pubDate>Tue, 10 Aug 2021 14:18:37 +0000</pubDate>
      <link>https://dev.to/manojap/how-to-handle-slatejs-document-in-nxut-keystone5-36j0</link>
      <guid>https://dev.to/manojap/how-to-handle-slatejs-document-in-nxut-keystone5-36j0</guid>
      <description>&lt;p&gt;I have a Nuxt-Keystone project in which have a list(keystone schema) called Post with post body as &lt;strong&gt;content&lt;/strong&gt; type which is a slatejs document&lt;/p&gt;

&lt;h1&gt;
  
  
  Problem
&lt;/h1&gt;

&lt;p&gt;I tried many way to output the post body (Document), it didn't work for me.&lt;/p&gt;

&lt;p&gt;Anybody know how to handle slatejs docs in a Vue component ? Please give me a hand.&lt;/p&gt;

</description>
      <category>nuxt</category>
      <category>keystone5</category>
      <category>slatejs</category>
    </item>
    <item>
      <title>Nuxt graphql server-middleware API</title>
      <dc:creator>MANOJ AP</dc:creator>
      <pubDate>Tue, 27 Jul 2021 03:48:06 +0000</pubDate>
      <link>https://dev.to/manojap/nuxt-graphql-server-middleware-api-36f8</link>
      <guid>https://dev.to/manojap/nuxt-graphql-server-middleware-api-36f8</guid>
      <description>&lt;h2&gt;
  
  
  Graphql
&lt;/h2&gt;

&lt;p&gt;Graphql is modern an alternative approach for the REST API invented by Facebook. It is used for fetch data from a server and put data back to a server , just like the regular API does. &lt;/p&gt;

&lt;p&gt;The Graphql shines where you want to fetch few data (required), where REST API fetch a bunch of data, it may cause fetching too much data. API have multiple end points where graphql have one. One of the problem with graphql, &lt;em&gt;it is not simple to create a graphql server&lt;/em&gt;, even though once it has been done ,using them is quiet simple. &lt;/p&gt;

&lt;h2&gt;
  
  
  Apollo and Express
&lt;/h2&gt;

&lt;p&gt;With Apollo server we can build and run a graphql server, for creating route for our graphql end point can utilize the node developers favorite &lt;em&gt;express&lt;/em&gt; module&lt;/p&gt;

&lt;h2&gt;
  
  
  Prisma
&lt;/h2&gt;

&lt;p&gt;Prisma is a ORM for JavaScript and Typescript, it let developers easily configure, create / migrate databases using models. One of the cool feature I love mostly is that , it can be configured with  few CLI commands like &lt;em&gt;init, migrate&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For initializing the Prisma install the developer dependency  &lt;strong&gt;npm i -d prisma&lt;/strong&gt; and initialize prisma with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;npx&lt;/span&gt; &lt;span class="nx"&gt;prisma&lt;/span&gt; &lt;span class="nx"&gt;init&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will generate necessary files under &lt;em&gt;Prisma&lt;/em&gt; folder, please open the file and configure database and models. For demonstration I have configured a Sqlite database, you can use other databases like mysql, postgres, Mongodb etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;//schema.prisma&lt;/span&gt;

&lt;span class="nx"&gt;datasource&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;provider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sqlite&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="nx"&gt;url&lt;/span&gt;      &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;file:./dev.db&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;generator&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;provider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;prisma-client-js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;model&lt;/span&gt; &lt;span class="nx"&gt;Contact&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt; &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;id&lt;/span&gt; &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;default&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;uuid&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
  &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;
  &lt;span class="nx"&gt;email&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note the &lt;em&gt;id&lt;/em&gt; field in the model, it is a primary key and also auto filled by the &lt;em&gt;uuid()&lt;/em&gt; function. One you done models go to generate the real database with &lt;strong&gt;migrate command&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx prisam migrate dev &lt;span class="nt"&gt;--name&lt;/span&gt; init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will generate the tables using the models we defined, to make sure we can use the prisma studio which runs on the port 555, also a standalone studio app is available.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;// run &lt;span class="k"&gt;in &lt;/span&gt;new terminal
npmx prisma studio
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the nuxtjs app we need the dependency @prisma/client, let's add them to our project&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nmp i &lt;span class="nt"&gt;-s&lt;/span&gt; @prisma/client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Graphql API
&lt;/h2&gt;

&lt;p&gt;In the Nuxt app , we can setup internal API for interacting with database using server middleware.&lt;br&gt;
In the project folder create a folder &lt;strong&gt;api&lt;/strong&gt; and inside the folder create a file &lt;strong&gt;graphql.ts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For create and run server routes, we can use the express framework the API should export the handler as in Nextjs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ApolloServer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;gql&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;apollo-server-express&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;PrismaClient&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@prisma/client&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;prisma&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;PrismaClient&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;typeDefs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;gql&lt;/span&gt;&lt;span class="s2"&gt;`

   type Todo{
        item:String!,        
        id:String
   }

   type Query{
       getAll: [Todo!]!
   }

   type Mutation{
       newTodo(item :String!):Todo
   } 
`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;resolvers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;Query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;getAll&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt;   &lt;span class="nx"&gt;prisma&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findMany&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;

    &lt;span class="na"&gt;Mutation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;async&lt;/span&gt;  &lt;span class="nf"&gt;newTodo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;_parent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;_args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

          &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newTodo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;prisma&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
              &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;_args&lt;/span&gt;
          &lt;span class="p"&gt;});&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;newTodo&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;server&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ApolloServer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
&lt;span class="nx"&gt;typeDefs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;resolvers&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;express&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;applyMiddleware&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;    
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/api&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  typeDefs
&lt;/h2&gt;

&lt;p&gt;typedefs constant contains graphql type definitions, Query and Mutations, it can be a user defined objects with multiple keys. For a complete data type list refer the official &lt;a href="https://graphql.org/learn/"&gt;documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Query
&lt;/h3&gt;

&lt;p&gt;As the name suggest the query is used to fetch some data, it uses the array synatax to fetch data.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mutations
&lt;/h3&gt;

&lt;p&gt;Mutations are for defining graphql part of create,update,delete functions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resolvers
&lt;/h2&gt;

&lt;p&gt;So the first part of our graphql is done with type,query and Mutations. But this is not enough, these are structures, we have to make them working, with resolver function.&lt;br&gt;
Resolvers are function to make the Query and Mutation in motion. &lt;/p&gt;
&lt;h2&gt;
  
  
  Nuxt-config
&lt;/h2&gt;

&lt;p&gt;For using Prisma client we need to use PrismaClient object. The API would not work at this point, it also required setup a middleware in the dedicated nuxt-config.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="c1"&gt;// Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode&lt;/span&gt;
   &lt;span class="na"&gt;ssr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="na"&gt;serverMiddleware&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;
     &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;~/api/graphql.ts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt;  
     &lt;span class="p"&gt;.....&lt;/span&gt;

&lt;span class="nx"&gt;and&lt;/span&gt; &lt;span class="nx"&gt;now&lt;/span&gt; &lt;span class="nx"&gt;the&lt;/span&gt; &lt;span class="nx"&gt;graphql&lt;/span&gt; &lt;span class="nx"&gt;playground&lt;/span&gt;  &lt;span class="nx"&gt;can&lt;/span&gt; &lt;span class="nx"&gt;be&lt;/span&gt; &lt;span class="nx"&gt;accessed&lt;/span&gt; &lt;span class="nx"&gt;at&lt;/span&gt; &lt;span class="na"&gt;http&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//localhost:3000/api/graphql&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>nuxt</category>
      <category>graphql</category>
      <category>api</category>
      <category>apollo</category>
    </item>
  </channel>
</rss>
