Unknown GraphQL environment setup In Hindi | GraphQL Tutorial in Hindi | My Project HD
X

GraphQL environment setup In Hindi | GraphQL Tutorial in Hindi

GraphQL environment setup In Hindi | GraphQL Tutorial in Hindi



इस Tutorial में, हम GraphQL के लिएenvironmental setup के बारे में जानेंगे। इस Tutorial में Example को execute करने के लिए आपको निम्नलिखित की आवश्यकता होगी -

  • Linux, macOS या Windows चलाने वाला Computer ।
  • एक web browser, preferably Google Chrome का latest version।
  • Node.js का latest LTS version। recent LTS version को recommended किया जाता है ।
  • VSCode के लिए extension GraphQL के साथ Visual Studio Code या अपनी पसंद का कोई भी code editor

How to Build a GraphQL server with Nodejs

हम Nodejs के साथ GraphQL Server Create करने के लिए एक step-wise approach से गुजरेंगे जैसा कि नीचे दिखाया गया है -

Step 1 − Verify Node and Npm Versions

NodeJs installing करने के बाद, terminal पर निम्नलिखित commands का उपयोग करके Node और npm के Version को verify करें -


C:\Users\Admin>node -v

v12.16.1


C:\Users\Admin>npm -v

6.13.4


Step 2 − Create a Project Folder and Open in VSCode

Project के Root Folder को Test App नाम दिया जा सकता है

नीचे दिए गए instructions का उपयोग करके visual studio code editor का उपयोग करके Folder खोलें -


C:\Users\Admin>mkdir test-app

C:\Users\Admin>cd test-app

C:\Users\Admin\test-app>code.


Step 3 − Create package.json and Install the Dependencies

एक package.json Filew बनाएँ जिसमें GraphQL Server Application की सभी dependencies होंगी।


नीचे दी गई Command का उपयोग करके dependencies Install करें -


C:\Users\Admin\test-app>npm install


Step 4 − Create Flat File Database in Data Folder

इस step में, हम Data को Store और retrieve करने के लिए flat files का उपयोग करते हैं। एक Folder Data बनाएं और दो Files Students.json और Colleges.json जोड़ें।


Following is the colleges.json file −


Following is the students.json file −


Step 5 − Create a Data Access Layer

हमें एक Datastore बनाने की आवश्यकता है जो Data Folder contents को लोड करता है। इस मामले में, हमें collection variables, Students और Colleges की Need है। जब भी Application को Data की आवश्यकता होती है, तो वह इन collection variables का उपयोग करता है।


Create file db.js with in the project folder as follows −


Step 6 − Create Schema File, schema.graphql

current project folder में एक Schema File बनाएँ और निम्नलिखित contents जोड़ें


Step 7 − Create Resolver File, resolvers.js

current project folder में एक resolver File बनाएँ और निम्नलिखित contents जोड़ें -

Step 8 − Create Server.js and Configure GraphQL

एक Server File बनाएँ और graphql को निम्नानुसार configure करें -


Run the command npm start as given below −


C:\Users\Admin\test-app>npm start


Run http://localhost:9000/graphiql. URL And Type the following query in the editor


The response from the server is given below −