classsed-graphql-mern-apollo's People
Forkers
deepak4735 iamwindy chef27615 harlyon slava-v23 herberthk radiksman ravikanthob futurelabhspforzheim elvz nadeeraka ramirezramirez125 ferko18 robertogallego pbandjamd lkraman hayriyigit jliukai thehuns ivonakov bobbyhalljr lenscorpx fbzr okamz yoheiumezu xit4 fouedj franknyn rabrad vipulnagarwal arung86 luchibobra7 greeninjack domo9293 juanpablom zihxiao hmusonye kayatechindia malcorehardcore698 husnain1301 dumitrubrinza marcusthellams jespinoza711 guru-ant couch-nic fakhruddin90 vannamnguyen sarvo-k sarthak1991 mahimaprakash madren rokador dreadchild jndisanze rahul1990gupta ppollono maxlemieux justinjgh teenkevo tard916 rlodhiya2502 bipinstha7 bhall2001 3nvy nelson-singleton itguymax psibal parul5sahoo yvantcheuffa martinrss3 wertiacoffee atiehamidi cadd devarajrc charliegroves tolufolorunso d14mittal tutv3 ebk13579 josedeyvi rachitr16 john-marcello dongkyoungpark eldyvoon erostribe josh-umahi si3mshady kolawolejohn iamrizwansk hassensaoud projects-repo brexibrexi mv29 codequinn ronandez dimasokta14 saraha2020 dm07032007 rajneeshksharma k-mungaiclasssed-graphql-mern-apollo's Issues
Single Post Error
×
TypeError: Cannot read property 'getPost' of undefined
const {
data: { getPost }
} = useQuery(FETCH_POST_QUERY, {
variables: {
postId
args not defined for react class 6 adding posts
Hi! I am having an error with regards to the adding of posts on react class 6 with Unhandled Rejection (Error): GraphQL error: args is not defined.
Unhandled Rejection (Error): GraphQL error: args is not defined
This happens even after removing the args
TypeError: Cannot convert undefined or null to object
this error of login and register page of errors.username errors.password are undefined
<Form.Input
label="Username"
placeholder="Username.."
name="username"
type="text"
value={values.username}
error={errors.username ? true : false}
onChange={onChange}
/>
TypeError: Cannot read property 'getPosts' of undefined
Home
C:/Users/Agon Misini/Desktop/merng/client/src/pages/Home.js:14
11 | const { user } = useContext(AuthContext);
12 | const {
13 | loading,
14 | data: { getPosts: posts }
| ^ 15 | } = useQuery(FETCH_POSTS_QUERY);
16 |
17 | return (
Getting error on register form "Cannot read property 'username' of undefined.
45 | name="username"
46 | type="text"
47 | value={values.username}
48 | error={errors.username ? true : false}
49 | onChange={onChange}
50 | />
51 | <Form.Input
so I know 'errors' is undefined.
const [addUser, {loading}] = useMutation(REGISTER_USER, { update(_, result){ console.log(result) props.history.push('/') }, onError(err){ console.log(err.graphQLErrors[0].extensions.exception.errors) setErrors(err.graphQLErrors[0].extensions.exception.errors) }, variables: values })
this is where we set the error property, right? Is it not setting it correctly? is there an updated way for graphql to set errors?
Single Post Type Error
Hey @hidjou, for some reason the code in the singlePost.js is not working properly. I think the data
shouldn't be restructured as the code is synchronous and the values are undefined unless you refresh the page.
Error in Import semantic-ui-css
Solution: Semantic-Org/Semantic-UI-React#4227
Uncaught (in promise) TypeError: Cannot read property 'extensions' of undefined
I am getting the following error in the registration page. Help please!!
Solving: Cast to ObjectId failed for value "" at path "_id" Error
Few months ago when I was following the tutorial, I was stuck at 1:18:00 because of this problem, after I found a fix, I don't remember where, I have created a gist with a solution and I have commented on the video telling people what causes the issue and a link to gist I've created. but I totaly forgot to put it here. so, here we go: Solving: Cast to ObjectId failed for value "" at path "_id" Error
in this Gist I am explaining the error and how to fix it
I am also working on another gist fixing another error that is happening because of the difference between the old apollo-client 2.6 and the new version 3.6 which I am using.
deleteComment Mutation Bug
I found a bug in the deleteComment Mutation.
When I tried to detete a non existing comment, an exception error was not caught. That is because the findIndex function returns -1 if the entry is not found. When you try to access the index in the if condition statement, the exception is thrown.
To catch this error, I introduced a new if block to check if commentIndex is >= 0 before executing the delete command and throw a new UserInputError if not. That fixed the issue.
Thanks a lot for your tutorial, it's doing wonders for me.
Making what you instructed in the video but still empty getPosts
@hidjou Salam.
I made the changes in config.js with a name of a Mongodb cluster, its password and changed the name of the database to its correct name like you instructed but still getting an empty getPosts like this:
2 Issues
I'm getting a couple errors. 1. Is when you click post with an empty body I get Unhandled Rejection (Error): GraphQL error: Post body must not be empty. The 2. is when I add more than 1 like I get Unhandled Rejection (Error): GraphQL error: user is not defined.
TypeError: Object(...)(...) is undefined in AuthRoute
AuthRoute.js
`
import React, { useContext } from "react";
import { Route, Redirect } from "react-router-dom";
import { AuthContext } from "../context/auth";
function AuthRoute({ component: Component, ...rest }) {
const { user } = useContext({ AuthContext });
return (
<Route
{...rest}
render={(props) =>
user ? : <Component {...props} />
}
/>
);
}
export default AuthRoute;
`
Gets the following Error:
TypeError: Object(...)(...) is undefined
TypeError: (destructured parameter).post is undefined ?
This tutorial was put up on https://www.youtube.com/watch?v=n1mdAPFq2Os only 3 weeks ago but a lot of the code is broken.
I'm getting the following error
TypeError: (destructured parameter).post is undefined
import React from "react";
import { Button, Form } from "semantic-ui-react";
import gql from "graphql-tag";
import { useForm } from "../util/hooks";
import { useMutation } from "@apollo/react-hooks";
function PostForm() {
const { values, onChange, onSubmit } = useForm(createPostCallback, {
body: "",
});
const [createPost, { error }] = useMutation(CREATE_POST_MUTATION, {
variables: values,
update(_, result) {
console.log(result);
values.body = "";
},
});
function createPostCallback() {
createPost();
}
return (
Create a post
<Form.Field>
<Form.Input
placeholder="Hello World"
name="body"
onChange={onChange}
value={values.body}
/>
Submit
</Form.Field>
);
}
const CREATE_POST_MUTATION = gqlmutation createPost($body: String!) { createPost(body: $body) { id body createdAt username likes { id username createdAt } likeCount comments { id body username createdAt } commentCount } }
;
export default PostForm;
Unhandled Rejection (Error): Cannot read property 'req' of undefined
When deleting a comment in singlePost view i ll get this error my code looks like this :
`
const [deletePostOrMutation] = useMutation(mutation, {
update(proxy, result) {
setModalShow(false);
if (!commentId) {
const data = proxy.readQuery({
query: FETCH_POSTS_QUERY
});
let newData = [...data.getPosts];
newData = data.getPosts.filter((p) => p.id !== postId);
proxy.writeQuery({
query: FETCH_POSTS_QUERY,
data: {
...data.getPosts,
getPosts: {
newData
}
}
});
}
if (callback) callback();
},
variables: {
postId,
commentId
}
})`
What am i missing here ? Thanks
useMutation response changes after reloading
I have successfully added another key named 'isAdmin: Boolean' to typeDefs's user and I return it, and to mongoose User Model as well.
When I query user using useMutation like so:
const [loginUser, { loading }] = useMutation(LOGIN_USER, {
update(_, { data: { login: userData }}) {
context.login(userData)
},
variables: values,
});
userData becomes:
{
"__typename": "User",
"id": "6295c18152e384a8ee61ee0f",
"username": "admin",
"email": "[email protected]",
"createdAt": "2022-05-31T07:19:29.647Z",
"isAdmin": true,
"token": "token-xxx"
}
i pass it to context and I see it in AuthContext.Provider component as long as I don't reload the page
but when I refresh the page it becomes:
{
"id": "6295c18152e384a8ee61ee0f",
"email": "[email protected]",
"username": "admin",
"iat": 1654054329,
"exp": 1654057929
}
is there anyway to keep isAdmin:value
in context after reloading?
'data' is not defined
- Issue located in: /client/src/pages/Home
const {
loading,
data: { getPosts: posts }
} = useQuery(FETCH_POSTS_QUERY);
-Issue description: 'data' is not defined (twice) 😢
-Context: I think the problem is due to the migration to @apollo/client 3.0 (they've discussed something about some changes regarding loading / data)
-How I solved it: :
const{
loading,
data={}
} = useQuery(FETCH_POSTS_QUERY);
const posts = data.getPosts;
Delete button issue
getPost From DAta Undefined
Server deployment error
I'm getting 404 error in the deploy server. Heroku log:
2021-02-20T03:40:07.767548+00:00 heroku[router]: at=info method=GET path="/" host=salty-bastion-35598.herokuapp.com request_id=62288037-601a-40da-b052-edd7c54235d3 fwd="201.237.16.163" dyno=web.1 connect=1ms service=51ms status=404 bytes=984 protocol=https
Check authentication middleware change on firebase authorization have error: UnhandledPromiseRejectionWarning
Please help, any idea how to solve? thx
// @Dependencies
const { AuthenticationError } = require('apollo-server-express')
const admin = require("../Server/client")
module.exports = async (context) => {
// @Header
const header = context.req.headers.authorization
// @validate
if(!header)
throw new Error('Musí sa uviesť hlavička overenia')
// @token
const token = header.split('Bearer ')[1]
// @validate
if(!token)
throw new Error('Musí sa uviesť hlavička overenia')
try {
// @auth
const auth = await admin.auth().verifyIdToken(token)
// @user
const user = await admin.firestore()
.collection('users')
.where('id', '==', auth.uid)
.limit(1)
.get()
return user.docs[0].data()
}
catch(error)
{
throw new AuthenticationError(error)
}
}
Tab highlight issue
"Cannot read property 'unshift' of undefined"
GRAPHQL > RESOLVERS > COMMENTS.JS
if (post) {
** post.comments.unshift({ **
body,
username,
createdAt: new Date().toISOString()
});
await post.save();
return post;
} else throw new UserInputError('Post not found');
Args not defined
When creating a new post i am getting an error "args not defined"
issue is with this line
if (args.body.trim() === "") {
throw new Error("Post body must not be empty");
}
But after removing args from that line , it is working fine.
.
args not defined.
Invalid/Expired token
I was typing the mutation of createPost. I first registered a new user and then logged it in. I copypasted the token on the Authorization headers however it is giving me the error Invalid/Expired Token
This is the register mutation-
mutation($registerInput: RegisterInput!) { register(registerInput: $registerInput) { username token } }
This is the login mutation-
mutation($username: String!, $password: String!){ login(username: $username, password: $password) { username token } }
and this is the createPost mutation-
mutation($body: String!){ createPost(body: $body) { body username } }
The photo of the error is below-
The github code is also below
https://github.com/Feanor96/social-media-website
cache update
Error: Invalid hook call. Hooks can only be called inside of the body of a function component.
I'm getting the following issue that I can'r fix:
localhost-1647473322391.log
Even after copying the folder 'client' from the source code, branch 'react2' still doesn't work.
I would really apreciate if someone know how to solve this.
Unable to get Single Post in graphql server
My typeDefs for getting single post
- getPost(postId: ID!): Post
Code for getPost
async getPost(_, { postId }) {
try {
const post = await Post.findById(postId);
if (post) {
return post;
} else {
throw new Error("Post not found");
}
} catch (err) {
throw new Error(err);
}
}
GraphQL Query in playground
query {
getPost(postId: "6128c4afc3f58e75065d3a2e"){
id
body
createdAt
username
}
}
it is returning null.
userData?
I can't seem to find out where to define this or pass into my login file and it keeps returning undefined
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.