Skip to content

Instantly share code, notes, and snippets.

import { gql } from 'apollo-boost';
/* PRODUCTS */
export const GET_PRODUCTS_QUERY = gql`
query {
products {
skuId
name
description
price
const { GraphQLServer } = require('graphql-yoga');
const typeDefs = `
type Query {
name: String!
age: Int!
isSingle: Boolean
}
`;
readme.md
@myogeshchavan97
myogeshchavan97 / jobs.json
Created July 1, 2020 10:35
Jobs API response
[
{
"id": "3c438a51-4c3e-49ee-bdd8-daaa93859c7c",
"type": "Full Time",
"url": "https://jobs.github.com/positions/3c438a51-4c3e-49ee-bdd8-daaa93859c7c",
"created_at": "Tue Jun 23 20:21:56 UTC 2020",
"company": "Connected Health Solutions BV",
"company_url": "http://www.carexs.com",
"location": "Amsterdam",
"title": "Lead Service Reliability Engineer ",
@myogeshchavan97
myogeshchavan97 / styles.scss
Last active October 19, 2021 23:40
CSS file
$body-color: #949ca5;
$default-padding: 2rem;
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
@myogeshchavan97
myogeshchavan97 / Image.js
Created July 1, 2020 10:02
Image Component
import React from 'react';
import { useState } from 'react';
import loading from '../images/loading.png';
/* https://via.placeholder.com/100x100?text=Loading */
const Image = ({ src, alt, ...props }) => {
const [isVisible, setIsVisible] = useState(false);
const changeVisibility = () => {
setIsVisible(true);
import { useEffect, useState } from 'react';
const useObserver = (targetRef) => {
const [isVisible, setIsVisible] = useState(false);
useEffect(() => {
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
if (!isVisible) {
@myogeshchavan97
myogeshchavan97 / HomePage.js
Created July 1, 2020 09:45
loadJobs function
const loadJobs = (selection) => {
const { dispatch } = props;
const { description, location, full_time, page = 1 } = selection;
let isLoadMore = false;
if (selection.hasOwnProperty('page')) {
isLoadMore = true;
}
dispatch(resetErrors());
setIsLoading(true);
dispatch(
@myogeshchavan97
myogeshchavan97 / Loader.js
Created July 1, 2020 09:40
Loader Component
import { useState, useEffect } from 'react';
import ReactDOM from 'react-dom';
const Loader = (props) => {
const [node] = useState(document.createElement('div'));
const loader = document.querySelector('#loader');
useEffect(() => {
loader.appendChild(node).classList.add('message');
}, [loader, node]);
@myogeshchavan97
myogeshchavan97 / JobItem.js
Created July 1, 2020 09:27
JobItem Component
import React, { useContext } from 'react';
import moment from 'moment';
import JobsContext from '../context/jobs';
const JobItem = (props) => {
const { onItemClick } = useContext(JobsContext);
const {
id,
type,
created_at,