Skip to content

Instantly share code, notes, and snippets.

View jtn-ms's full-sized avatar
🏘️
working from home

Brian G. jtn-ms

🏘️
working from home
  • remote
View GitHub Profile
@jtn-ms
jtn-ms / git - rename branch.sh
Created July 21, 2022 14:49
git tech - renaming branch
git checkout <oldname>
git branch -m <newname>
git push origin -u <newname>
git push origin --delete <oldname>
export const ADD_CLIENT = gql`
mutation addClient($name: String!,
$email: String!,
$phone: String!,
) {
addClient(name: $name, email: $email, phone: $phone) {
id
name
email
phone
import {gql} from '@apollo/client';
export const DELETE_CLIENT = gql`
mutation deleteClient($id: ID!) {
deleteClient(id: $id) {
id
name
email
phone
}
import {gql} from '@apollo/client';
export const GET_CLIENTS = gql`
query getClients {
clients {
id
name
email
phone
}
@jtn-ms
jtn-ms / AddClient.jsx
Created July 21, 2022 13:25
react graphql -add using Modal
import { useState } from "react";
import {FaUser} from 'react-icons/fa';
import {useMutation} from '@apollo/client'
import { ADD_CLIENT } from "../mutations/clientMutations";
import { GET_CLIENTS } from "../queries/clientQueries";
export default function AddClientModal() {
const [name,setName] = useState('');
const [email,setEmail] = useState('');
const [phone,setPhone] = useState('');
@jtn-ms
jtn-ms / App.js
Last active July 21, 2022 13:19
react graphql - query
import Header from "./components/Header";
import Clients from "./components/Clients";
import {ApolloProvider, ApolloClient, InMemoryCache} from '@apollo/client'
const cache = new InMemoryCache({
typePolicies:{
Query: {
fields: {
clients: {
merge(existing,incoming) {
@jtn-ms
jtn-ms / .babelrc
Last active September 4, 2022 20:30
react webpack - absolute path setting for webpack has nothing to do with jsconfig in create-react-app & react-scripts
{
"presets": ["@babel/preset-env","@babel/preset-react"]
}
@jtn-ms
jtn-ms / index.js
Created July 20, 2022 17:20
access granted to client using "cors"
const express = require('express');
const colors = require('colors');
const cors = require('cors');
require('dotenv').config();
const {graphqlHTTP} = require('express-graphql');
const schema = require('./schema/schema');
const port = process.env.PORT ||5000;
const app = express();
@jtn-ms
jtn-ms / schema.mutation.js
Created July 20, 2022 17:17
CRUD - mongoose, graphql, express
const Project = require('../models/Project');
const Client = require('../models/Client');
const {
GraphQLObjectType,
GraphQLID,
GraphQLString,
GraphQLSchema,
GraphQLList,
GraphQLNonNull,
@jtn-ms
jtn-ms / models.project.js
Last active July 20, 2022 17:13
mongoose - model, schema, mixed type
const mongoose = require('mongoose');
const ProjectSchema = new mongoose.Schema({
name: { type:String,},
description : { type: String,},
clientId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Client',
},
status: {