Code Monkey home page Code Monkey logo

incridea-client's Introduction

Incridea client repo

Tech Stack

Frontend

Docs

Local setup

  1. Clone the repository
git clone https://github.com/incridea-23/incridea-client.git
  1. Install all dependencies
npm i
  1. Run the development server:
npm run dev

Open http://localhost:3000 with your browser to see the result.

Apollo client workflow

  1. Write a query or mutation under /src/graphql folder. Refer Playground for syntax.

    Query Example
    query GetAllUsers {
      users {
        id
        name
        email
      }
    }
    Mutation Example
    mutation SignUp($email: String!, $name: String!, $password: String!) {
      signUp(data: { email: $email, name: $name, password: $password }) {
        __typename
        ... on Error {
          message
        }
        ... on MutationSignUpSuccess {
          __typename
        }
      }
    }
  2. Run the below command to generate the types for your queries/mutations.

npm run codegen
  1. Refer the below examples for queries and mutations.

Querying example

Data fetching options in Next.js

1. CSR
import { useQuery } from "@apollo/client";
import { NextPage } from "next";
import { GetAllUsersDocument } from "../generated/generated";

const CSR: NextPage = () => {
  const { data, loading, error } = useQuery(GetAllUsersDocument);
  const users = data?.users;

  return (
    <div>
      {loading && <div>Loading...</div>}
      {error && <div>Error: {error.message}</div>}
      {users?.map((user) => (
        <div key={user.id}>{user.name}</div>
      ))}
    </div>
  );
};

export default CSR;
2. SSG
import { NextPage } from "next";
import { GetAllUsersDocument } from "../generated/generated";
import { initializeApollo } from "../lib/apollo";

const SSG: NextPage<{
  users: {
    id: string;
    name: string;
  }[];
}> = ({ users }) => {
  return (
    <div>
      {users.map((user) => (
        <div key={user.id}>{user.name}</div>
      ))}
    </div>
  );
};

export const getStaticProps = async () => {
  const apolloClient = initializeApollo();
  const res = await apolloClient.query({
    query: GetAllUsersDocument,
  });
  return {
    props: {
      users: res.data.users,
    },
  };
};

export default SSG;
3. SSR

Replace getStaticProps to getServerSideProps.

4. ISR

Add an invalidate option to SSG.

5. On-demand ISR

Read about it here.

Mutation example

Example
import { SignUpDocument } from '@/src/generated/generated';
import { useMutation } from '@apollo/client';

signUpMutation({
variables: {
name: userInfo.name,
email: userInfo.email,
password: userInfo.password,
},
})
.then((res) => {
if (res.data?.signUp.\_\_typename === 'MutationSignUpSuccess') {
router.push('/auth/verify-email');
}
})
.catch((err) => {
return err;
});

Note Refer Sign up mutation for full code.

Branching and Making PRs

  1. After cloning and setting up the environment, checkout to a new branch (name is related to your task, for eg: feat/user-login, fix/image-overflow)
git checkout -b <branch_name>
  1. Make the required changes according to your task.
//Staging changes
git add .
//Commiting changes
git commit -m <short message about task>
//Pushing changes
git push origin <branch_name>
  1. Make a Pull request to main branch, and wait for it to get reviewed by someone in the team. If there are review comments, make a new commit making those changes to the same branch to address those comments.

Development Notes

  • Please join Incridea org on Trello from the invite link shared on Discord.
  • Use the HeadComponent while developing a new page and provide it with suitable title and description for better SEO.
  • Use semantic commit messages to keep the commit history clean.
Semantic commits
<type>[optional scope]: <description>

[optional body]

[optional footer(s)]

  • feat – a new feature is introduced with the changes
  • fix – a bug fix has occurred
  • chore – changes that do not relate to a fix or feature and don't modify src or test files (for example updating dependencies)
  • refactor – refactored code that neither fixes a bug nor adds a feature
  • docs – updates to documentation such as a the README or other markdown files
  • style – changes that do not affect the meaning of the code, likely related to code formatting such as white-space, missing semi-colons, and so on.
  • test – including new or correcting previous tests
  • perf – performance improvements
  • ci – continuous integration related
  • build – changes that affect the build system or external dependencies
  • revert – reverts a previous commit
```

incridea-client's People

Contributors

nagarajpandith avatar swasthikshetty10 avatar jevil25 avatar prabhuomkar9 avatar numannaeem avatar keerthan-ns avatar exgene avatar aniruddha-upadhya-k avatar satwikrprabhu avatar geekyankush avatar nandanpi avatar adithya11811 avatar srivatsarupadhya avatar satviknayak avatar rakshithx09 avatar amrith-r-naik avatar padmashreeshetty123 avatar karthikshetty5 avatar bhavyanayak04 avatar varunpai314 avatar prg2308 avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.