Course code for the GraphQL with React course by Stephen Grider at Udemy.
- Working on Auth client
These are query and mutation examples to remember the syntax when it's more than just a simple query or mutation.
If you name your queries and mutations, then you can have multiple ones there and pressing the go button will then show a list of queries and mutations to run. e.g.
mutation signup {
signup(email: "julian@example.com", password: "password") { email }
}
mutation login {
login(email: "julian@example.com", password: "password") { email }
}
mutation loginBad {
login(email: "julian@example.com", password: "notpassword") { email }
}
mutation logout {
logout { email }
}
{
first: company(id: "1") {
...companyDetails
}
company(id: "2") {
...companyDetails
}
}
mutation {
addCompany(name: "Woolworth") {
...companyDetails
}
}
fragment companyDetails on Company {
id, name, description
}
query Song($id: ID!) {
song(id: $id) {
id, title
}
}
mutation AddSong($title: String!) {
addSong(title: $title) {
id
}
}
I have updated the version of most of the npm modules in use in the lyrical and auth applications.
-
I am using the latest React (16.10.x) and Apollo Client (2.x).
-
The latest Apollo client link seems to default to
credentials: 'same-origin'
. -
it is not necessary to pass
{ dataIdFromObject: o => o.id }
to ApolloClient because that is essentially the default (at least in v2.x). -
Currently (03-Oct-2019), I have not updated to the latest react-router on either app.
-
I am using React Functional Components and Hooks instead of classes.
-
My user query is called currentUser.
-
For both lyrical and auth, my queries and mutations are in a single file in the client:
.../queries/index.js
. I think that in a large app, I would make more than one file for queries and mutations. I would probably not put each query or mutation in a separate file, but group them by function. -
React hooks really shine in the auth
requireAuth()
.useEffect(...)
is much more effective than the method that Stephen uses.
I have used Git at the command-line for more than 10 years. Over that time, I have tried many different graphical shells for Git, without finding one that was easier and nicer to use than the command-line (in my view).
I have now found that GitKraken is an excellent Git shell and would advise using it to everyone.
I have no connection with GitKraken or Axosoft, other than as a satisfied user.
If you have any questions about this repository, or any others of mine, please don't hesitate to contact me.