GraphQL Tutorial #32 - query variables

preview_player
Показать описание

----- COURSE LINKS:

======== Other Tutorials =========

----- NODE.JS TUTORIALS

----- MONGODB TUTORIALS

----- REACT TUTORIALS

======== Social Links ==========

Рекомендации по теме
Комментарии
Автор

Shaun, it's October 2020 and this content is still great. Thanks so much!

markgalante
Автор

Amazing tut as usual, we get the quality of paid courses for free, thanks Shaun you are the Best😆😆😆

SamA-sjwk
Автор


import { getAuthorQuery, addBookMutation } from '../queries/queries'

const AddBooks =()=>{
const {loading, error, data} = useQuery(getAuthorQuery);
const [addBook, { newData }] =
const [name, setName] = useState('');
const [genre, setGenre] = useState('');
const [ authorId, setAuthorId]= useState('')

const getAuthors = () => {
if (loading) return <option>Loading Authors...</option>;
if (error) return <option>Error Loading Authors :(</option>;


return (
<option value="">Select Author</option>,
data.authors.map((author) => (
<option key={author.id} value={author.id}>
{author.name}
</option>
))
);
};

const handleSubmit=(e)=>{
e.preventDefault()
addBook({
variables:{
name,
genre,
authorId
}
})
}

return (
<form id="add-book" onSubmit={handleSubmit}>
<div className="field">
<label>Book name:</label>
<input type="text" onChange =
</div>
<div className="field">
<label>Genre:</label>
<input type="text" onChange =
</div>
<div className="field">
<label>Author:</label>
<select onChange =
<option>Select author</option>
{ getAuthors() }
</select>
</div>
<button>+</button>
</form>
);
}

export default AddBooks;

danielgebremedhin
Автор

The compose method is no longer supported for binding getAuthorsQuery and addBookMutation, I am getting some different results when using lodash.flowRight as an alternative

mridulsetia
Автор

could you do a series on Electron JS ?

alipoetry
Автор

For what do we typehint mutation($name:String!) => here it says the name variable is required and should be a String.

But if I input an Integer it also saves to the database. So for what are we writing this?

Since at the end I anyways have to do validations in my Mongoose schema, I guess?
Appreciate your videos. Thank you :)

TuberroX
Автор

I get an empty object for addBookMutation. I am usig function paradigm with hooks.

JohnDoe-szjh
Автор

Hello Sir
The way you teach is really awesome !
But I really wanna know one thing.
What is the path that you take to learn new stuff like this yourself!?
Through docs seeing examples and something like that.
Coz whenever i try that I mostly get lost.😶
Would really appreciate a good explanation
Thank you❣️❣️

pulkitvalecha
Автор

Thank you so much Shaun for this amazing course.

I had an error 'compose' is not exported from 'react-apollo'

workaround is:
1) npm install lodash.flowright
2) import * as compose from 'lodash.flowright'

abdelmoneimnafea
Автор

I am using apollo with hooks, and ID provided on mutation seems to be not working. Everything goes fine as long as i don't provide the scalar type of: ID for authorId. Had anyone similar problem and know how to fix this?

kalush
Автор

i'm getting the error: "this.props.addBookMutation' is not function. i tried using addBookMutation() and still not working

amarnarayanpasuperti
Автор

{message: "Field "addBook" argument "authorid" of type "ID!" is required but not provided.", …}


how to solve this error?

adeelasif
Автор

is there a functional component version of this tutorial? I really need it, would be best if you can help thanks a lot

benji
Автор

Is someone getting the next?
That doesn't work, that only returns a Unhandled Rejection (Error): Response not successful: Received status code 400

oscararmenta
Автор

I kept getting an error saying ["$authorId" for type "ID!" used in position expecting type "String!"].
I had to change $authorId:ID! to $authorID:String!

Not sure why, but it works.
Hope this helps someone :)

carlibotes
Автор

I'm getting the error: "this.props.addBookMutation'' is not a function, help???

arthuradurcolman
Автор

graphql is stupid in the JavaScript actual implementation is off.

markoshivapavlovic
Автор

Please change the font of editor with font like a operator mono or fira code

eslamzanaty
welcome to shbcf.ru