Setting Up React with GraphQL

Setting Up React with GraphQL

Ben Awad

6 лет назад

11,621 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Cultive Teritoire
Cultive Teritoire - 18.05.2019 03:23

merci bro

Ответить
Andres Alcocer
Andres Alcocer - 02.02.2019 23:20

Do we need to add a query component when fetching data from graphql? Thanks.

Ответить
Rofi Areiv
Rofi Areiv - 17.01.2019 11:35

man, can you give me new tutorial using apollo 2, thanks

Ответить
MuLtDirectX
MuLtDirectX - 15.10.2018 11:52

Man, you are the greatest teacher ever!

Ответить
Christopher Enriquez
Christopher Enriquez - 13.02.2018 12:13

Can't follow, im new to react :(

Ответить
Gabriel
Gabriel - 27.12.2017 01:20

TypeError: Object(...) is not a function in const mutation = gql`mutation ...` someone knows?

Ответить
Benjamin Brooke
Benjamin Brooke - 12.11.2017 23:38

good stuff. im on cloud 9 so i had to use cors as well. configuring like this seems to work:
server.use('*', cors({ origin: <whitelisted url aka client> }));.
the npm package - concurrently - is pretty cool too. lets you run both apps with one npm start command easily.
psyched i have the time to check this series out, my first time not using mongoDB, i didn't know previously but postgres is pre installed into c9 workspaces. i like how you pass models into context, this really cuts down on the amount of code i would normally use in resolvers. i wonder a similar approach works with a mongo setup.
i usually import each model separately, idk creating new data in mongoose is a little different.

Ответить
Francis N
Francis N - 09.11.2017 08:21

Hey Ben, great video. I am getting this error in my console: `bundle.js:sourcemap:29431 Uncaught TypeError: (0 , _reactApollo.gql) is not a function` and am not sure what it means.

Ответить
Diahron Grismore
Diahron Grismore - 01.11.2017 18:43

import React from 'react';
import { gql, graphql } from 'react-apollo';

const Home = ({ data: { allUsers = [] } }) => allUsers.map(u => <h1 key={u.id}>{u.email}</h1>);

const allUsersQuery = gql`
{
allUsers {
id
email
}
}
`;
export default graphql(allUsersQuery)(Home);

Ответить
Diahron Grismore
Diahron Grismore - 01.11.2017 18:38

const allUsersQuery = gql`
{
allUsers {
id
email
}
}
`;

Ответить
Diahron Grismore
Diahron Grismore - 01.11.2017 18:28

I am getting this error: TypeError: Object(...) is not a function
./src/routes/Home.js
src/routes/Home.js:6
I can't figure it out. Code look exactly as yours, but there is something I'm missing. Any help would be appreciated. I am still searching for an answer.

Ответить
hrmny
hrmny - 29.10.2017 01:47

you'll probably want
```
env: {
'browser': true
},
```
in the eslint config instead of explicitly defining the global

Ответить