Ecommero
  • Introduction
  • High Level Architecture
  • Installation
    • How to deploy in local machine
    • How to deploy in production
  • FAQS
  • License
  • ChangeLog
  • API SERVER
    • Introduction
    • Technologies
    • Packages Json
    • Outline
    • Model Diagram
    • Routes
    • Queries Mutations and Fragments
    • Resolvers
      • Auth Resolvers
      • User Resolvers
      • Configuration Resolver
      • Category Resolver
      • Sub Category Resolver
      • Product Resolver
  • ADMIN WEB DASHBOARD
    • Introduction
    • Technologies
    • Packages Json
    • Folder Structure
    • Components
    • Customize
  • CUSTOMER APP
    • Components
    • Introduction
    • Folder Structure
    • Packages Json
    • Technologies Used
    • Guide
      • Customize
Powered by GitBook
On this page
  • Queries Mutations and Fragments
  • Queries

Was this helpful?

  1. API SERVER

Queries Mutations and Fragments

PreviousRoutesNextResolvers

Last updated 4 years ago

Was this helpful?

Queries Mutations and Fragments

Queries

Fetching data in a simple, predictable way is one of the core features of . are used to fetch data attach the result to your UI. In frontend mobile and dashboard we have written multiple queries in mobile app located inshopping-cart-app/src/apollo/server.js in Dashboard Queries are located in shopping-cart-admin/src/apollo/server.js As an example look into shopping-cart-app/src/apollo/server.js and the constant getNotifications the query is written as

query categories{
    categories{
    _id
    order
    status
    }
}

On line 1 categories is the query name for the frontend while on line 2 categories is the query name for backend. The parameters written inside notifications are output parameters they will be returned by the GraphQL endpoint.

Now let's take a look at another example this time we are going to pass some parameters as input to a query. The constant foods is a simple example for this located at food-delivery-app/src/apollo/server.js

query SubCategoriesById($id:String!){
    subCategoriesById(id:$id){
    _id
    title
    image
    category{
      _id
      title
    }
}

On line 1 SubCategoriesById is the query name for the frontend we are passing a String where it's variable name is id $ sign is used for variable name while ! is used for required field. On line 2 subCategoriesById is the query name for the backend.

Apollo Client
Queries
GraphQL