Create a simple to-do app and integrate it with Auth0. This step in the GraphQL tutorial walks you through creating a basic UI with React.
create-react-app
command.
src/App.js
with the below content to include the Apollo
client setup.
ApolloProvider
and
wrapped our App
so that its accessible throughout the app.
src/GraphQLData.js
and add the following.
src/App.js
replacing all the code. Letβs now create the functions to
add a todo and get todos.
domain
and clientid
in the file
src/auth_template.json
. Check this
link
for more information.http://localhost:3000
to βAllowed Callback URLsβ, βAllowed Web Originsβ
and βAllowed Logout URLsβ.src/App.js
file letβs update our src/index.js
file with the following code.
src/auth_template.json
file must be configured with your auth0 credentials.
Here is a reference
Here
Letβs also add definitions for updating, deleting and clearing all tasks to
src/GraphQLData.js
. Letβs also add the constants user
, isAuthenticated
,
loginWithRedirect
and logout
which they receive from the variable
useAuth0
. We also create a constant called logInOut
that contains the logic
to know if the user is logged in or not. This variable will show a button to
login or logout depending on the status of logged in or logged out. Note that
before calling the component Todos we call our variable {logInOut}
so that our
login button appears above the app.
src/GraphQLData.js
file
with the remaining queries.