├── .github └── workflows │ └── stale.yml ├── .gitignore ├── LICENSE ├── README.md ├── bin └── bd.sh ├── blog-post-app ├── .gitignore ├── README.md ├── babel.config.js ├── blog-post-react │ ├── .gitignore │ ├── README.md │ ├── blog-1.png │ ├── package-lock.json │ ├── package.json │ ├── public │ │ ├── index.html │ │ ├── manifest.json │ │ └── robots.txt │ ├── schema.graphql │ ├── screenshot.png │ ├── src │ │ ├── App.test.js │ │ ├── components │ │ │ ├── App.js │ │ │ ├── AuthorSelect.js │ │ │ ├── CreatePost.js │ │ │ ├── EditPost.js │ │ │ ├── Header.js │ │ │ ├── Post.js │ │ │ ├── PostList.js │ │ │ └── ViewPost.js │ │ ├── index.js │ │ └── styles │ │ │ └── index.css │ └── yarn.lock ├── blog-post-vue │ ├── .gitignore │ ├── README.md │ ├── babel.config.js │ ├── package.json │ ├── public │ │ ├── favicon.ico │ │ └── index.html │ ├── schema.graphql │ ├── src │ │ ├── App.vue │ │ ├── assets │ │ │ └── logo.png │ │ ├── components │ │ │ ├── AuthorSelect.vue │ │ │ ├── Header.vue │ │ │ └── Post.vue │ │ ├── main.js │ │ ├── router.js │ │ └── views │ │ │ ├── CreatePost.vue │ │ │ ├── EditPost.vue │ │ │ ├── PostList.vue │ │ │ └── ViewPost.vue │ ├── static │ │ └── style.css │ └── yarn.lock ├── package.json ├── public │ ├── favicon.ico │ └── index.html ├── schema.graphql ├── src │ ├── App.vue │ ├── assets │ │ └── logo.png │ ├── components │ │ ├── AuthorSelect.vue │ │ ├── Header.vue │ │ └── Post.vue │ ├── main.js │ ├── router.js │ └── views │ │ ├── CreatePost.vue │ │ ├── EditPost.vue │ │ ├── PostList.vue │ │ └── ViewPost.vue ├── static │ └── style.css └── yarn.lock ├── charting ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── robots.txt ├── schema.graphql ├── screenshots │ ├── home.png │ └── metrics.png └── src │ ├── App.css │ ├── App.js │ ├── App.test.js │ ├── apollo-client.js │ ├── assets │ └── images │ │ ├── imageThree.jpeg │ │ ├── logo.png │ │ ├── logo.svg │ │ ├── search.svg │ │ ├── settings.svg │ │ └── user.svg │ ├── components │ ├── card.js │ ├── content.js │ ├── formField.js │ ├── navbar │ │ ├── index.js │ │ └── navbar.style.js │ ├── search.js │ ├── sidebar │ │ ├── index.js │ │ └── sidebar.style.js │ └── ugly-button.js │ ├── index.css │ ├── index.js │ ├── logo.svg │ ├── pages │ ├── add-data.js │ ├── generate-data.js │ ├── home.js │ ├── metrics.js │ └── not-found.js │ ├── serviceWorker.js │ ├── setupTests.js │ ├── theme.js │ └── utils │ └── history.js ├── chat-app-react ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── index.html │ ├── manifest.json │ └── robots.txt └── src │ ├── ApolloSetup.js │ ├── App.js │ ├── Post.js │ ├── Query.js │ ├── index.css │ └── index.js ├── dev-jokes ├── .gitignore ├── LICENSE ├── README.md ├── auth0_snippets │ ├── addUserRule.js │ └── setUserRole.js ├── backend │ ├── .gitignore │ ├── app.js │ ├── controllers │ │ └── sign_s3.js │ ├── package-lock.json │ └── package.json ├── netlify.toml ├── one-click │ ├── mutations.graphql │ └── schema.graphql ├── package-lock.json ├── package.json ├── public │ ├── _headers │ ├── _redirects │ ├── background │ │ ├── blue.jpg │ │ ├── green.jpg │ │ ├── light-green.jpg │ │ ├── pink.jpg │ │ ├── red.jpg │ │ ├── skin.jpg │ │ ├── white.jpg │ │ └── yellow.jpg │ ├── favicon.ico │ ├── index.html │ ├── manifest.json │ ├── robots.txt │ └── screenshots │ │ ├── approve.jpg │ │ ├── create.jpg │ │ └── home.jpg ├── s3_snippets │ ├── cors.xml │ └── getSignedURL.js └── src │ ├── App.css │ ├── App.js │ ├── assets │ └── images │ │ ├── background.jpeg │ │ ├── background.jpg │ │ ├── background │ │ ├── blue.jpg │ │ ├── green.jpg │ │ ├── light-green.jpg │ │ ├── pink.jpg │ │ ├── red.jpg │ │ ├── skin.jpg │ │ ├── white.jpg │ │ └── yellow.jpg │ │ ├── imageThree.jpeg │ │ ├── logo.png │ │ ├── logo.svg │ │ ├── search.svg │ │ ├── settings.svg │ │ ├── slash.png │ │ └── user.svg │ ├── components │ ├── auth │ │ ├── loginButton.js │ │ ├── logoutButton.js │ │ └── signupButton.js │ ├── card │ │ ├── cardModal.js │ │ ├── postCard.js │ │ └── postModal.js │ ├── content.js │ ├── create │ │ ├── bgGallery.js │ │ └── canvasImage.js │ ├── loading.js │ ├── masonryGrid.js │ ├── navbar │ │ ├── index.js │ │ └── navbar.style.js │ ├── privateRoute.js │ ├── selector.js │ ├── sidebar │ │ ├── index.js │ │ └── sidebar.style.js │ ├── tagSelector.js │ └── tagger.js │ ├── config.js │ ├── gql │ ├── queryData.js │ └── schema.graphql │ ├── index.css │ ├── index.js │ ├── pages │ ├── approve.js │ ├── create.js │ ├── flagged.js │ ├── home.js │ ├── not-found.js │ └── profile.js │ ├── theme.js │ └── utils │ ├── apollo-client.js │ ├── auth0-provider-with-history.js │ ├── history.js │ ├── imperativeQuery.js │ └── utils.js ├── dgraph-lambda ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── schema.graphql └── src │ └── index.js ├── donors-app ├── .graphqlrc.json ├── README.md ├── codegen.ts ├── package.json ├── public │ ├── diggy.png │ ├── favicon.ico │ ├── index.html │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── robots.txt ├── src │ ├── App.css │ ├── App.test.tsx │ ├── App.tsx │ ├── components │ │ ├── Schools.tsx │ │ └── operations.ts │ ├── gql │ │ ├── fragment-masking.ts │ │ ├── gql.ts │ │ ├── graphql.ts │ │ └── index.ts │ ├── index.css │ ├── index.tsx │ ├── logo.svg │ ├── react-app-env.d.ts │ ├── reportWebVitals.ts │ └── setupTests.ts └── tsconfig.json ├── instaclone ├── .env ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── robots.txt └── src │ ├── App.js │ ├── Components │ ├── ApolloWrapper.js │ ├── AuthButtons.js │ ├── Feed.js │ ├── GenericButton.js │ ├── LogInButton.js │ ├── LogOutButton.js │ └── Nav.js │ ├── GraphQL │ └── Queries.js │ ├── index.js │ └── logo.svg ├── pokedex ├── .gitignore ├── .prettierignore ├── .prettierrc.js ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── robots.txt ├── screen1.png ├── snippets │ ├── add-all-pokemon.graphql │ ├── add-single-pokemon.graphql │ ├── delete-single-pokemon.graphql │ ├── query-pokemon-by-captured.graphql │ ├── query-pokemon-by-type-and-by-captured.graphql │ ├── query-pokemon-by-type.graphql │ ├── query-pokemon-names.graphql │ ├── query-pokemon.graphql │ ├── schema.graphql │ └── update-single-pokemon.graphql ├── src │ ├── App.js │ ├── Filters.js │ ├── PokemonCard.js │ ├── PokemonCardsList.js │ ├── graphQLUtils.js │ ├── index.css │ ├── index.js │ ├── pokemon-logo.png │ ├── serviceWorker.js │ └── setupTests.js └── yarn.lock ├── stackoverflow-app ├── README.md ├── apollo-dgraph │ ├── .gitignore │ ├── README.md │ ├── codegen.yaml │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── dgraph │ │ │ ├── dgraph.graphql │ │ │ └── index.ts │ │ ├── resolvers │ │ │ ├── index.ts │ │ │ ├── mutation.ts │ │ │ └── query.ts │ │ ├── schema.ts │ │ ├── schema │ │ │ └── schema.graphql │ │ ├── server.ts │ │ └── types │ │ │ └── gql.d.ts │ └── tsconfig.json ├── frontend │ ├── .gitignore │ ├── README.md │ ├── auth0hook.js │ ├── package-lock.json │ ├── package.json │ ├── public │ │ ├── dgraph.png │ │ ├── index.html │ │ ├── manifest.json │ │ └── robots.txt │ ├── schema.graphql │ ├── src │ │ ├── App.test.js │ │ ├── auth_config.json │ │ ├── components │ │ │ ├── App.js │ │ │ ├── CreateQuestion.js │ │ │ ├── Header.js │ │ │ ├── PrivateRoute.js │ │ │ ├── Question.js │ │ │ ├── QuestionList.js │ │ │ └── ViewQuestion.js │ │ ├── index.js │ │ ├── react-auth0-spa.js │ │ ├── styles │ │ │ └── index.css │ │ └── utils │ │ │ └── history.js │ └── yarn.lock ├── graphql-server-gateway │ ├── .gitignore │ ├── index.js │ ├── package-lock.json │ └── package.json ├── try-apollo-schema │ ├── .gitignore │ ├── example1.js │ ├── example2.js │ ├── example3.js │ ├── index.js │ ├── package-lock.json │ └── package.json └── v1-frontend │ ├── .gitignore │ ├── README.md │ ├── auth0hook.js │ ├── package-lock.json │ ├── package.json │ ├── public │ ├── dgraph.png │ ├── index.html │ ├── manifest.json │ └── robots.txt │ ├── schema.graphql │ ├── src │ ├── App.test.js │ ├── auth_config.json │ ├── components │ │ ├── App.js │ │ ├── CreateQuestion.js │ │ ├── Header.js │ │ ├── PrivateRoute.js │ │ ├── Question.js │ │ ├── QuestionList.js │ │ └── ViewQuestion.js │ ├── index.js │ ├── react-auth0-spa.js │ ├── styles │ │ └── index.css │ └── utils │ │ └── history.js │ └── yarn.lock ├── surveyo ├── .gitignore ├── .prettierrc.json ├── LICENSE ├── README.md ├── __generated__ │ └── globalTypes.ts ├── _redirects ├── apollo.config.js ├── auth0_snippets │ ├── add_user_rule.js │ ├── client_credentials_hook.js │ └── post_user_registration_hook.js ├── netlify.toml ├── package.json ├── public │ ├── Charts.gif │ ├── Create-Form.gif │ ├── charts.png │ ├── dashboard.png │ ├── favicon.svg │ ├── graphiql.png │ ├── index.html │ ├── loginPage.png │ ├── logo.svg │ ├── manifest.json │ └── robots.txt ├── sample_form.graphql ├── schema.graphql ├── schema_noauth.graphql ├── src │ ├── ApolloConfig.js │ ├── App.css │ ├── App.test.tsx │ ├── App.tsx │ ├── AuthConfig.json │ ├── Charts │ │ ├── Chart.tsx │ │ ├── NetPromoterScore.tsx │ │ ├── Rating.tsx │ │ ├── SingleChoice.tsx │ │ ├── Text.tsx │ │ ├── __generated__ │ │ │ └── GetChartData.ts │ │ ├── common.tsx │ │ ├── index.tsx │ │ └── query.tsx │ ├── Dashboard │ │ ├── __generated__ │ │ │ ├── DeleteForm.ts │ │ │ ├── GetCsvResponses.ts │ │ │ ├── GetSurveys.ts │ │ │ └── UpdateForm.ts │ │ ├── csv.tsx │ │ ├── index.tsx │ │ └── query.tsx │ ├── Form │ │ ├── NetPromoterScore.tsx │ │ ├── __generated__ │ │ │ ├── AddResponse.ts │ │ │ └── GetForm.ts │ │ ├── form.tsx │ │ ├── index.tsx │ │ └── query.tsx │ ├── FormCreator │ │ ├── __generated__ │ │ │ └── AddForm.ts │ │ ├── index.tsx │ │ └── query.tsx │ ├── Graphiql │ │ ├── index.css │ │ └── index.tsx │ ├── common │ │ ├── FormClosed.tsx │ │ ├── Result404.tsx │ │ ├── Result500.tsx │ │ └── index.tsx │ ├── history.js │ ├── images │ │ ├── logoDark.svg │ │ ├── logoLight.svg │ │ └── slash-logo.png │ ├── index.tsx │ ├── react-app-env.d.ts │ ├── serviceWorker.ts │ └── setupTests.ts ├── tsconfig.json └── yarn.lock ├── todo-app-noauth ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── manifest.json │ └── robots.txt ├── schema.graphql ├── src │ ├── App.css │ ├── App.js │ ├── GraphQLData.js │ ├── TodoApp.js │ ├── TodoFooter.js │ ├── TodoItem.js │ ├── Utils.js │ ├── defs.js │ ├── history.js │ ├── index.js │ └── setupTests.js ├── todo-1.png ├── todo-2.png └── todo-graph.png ├── todo-app-react ├── .gitignore ├── README.md ├── one-click │ ├── mutations.graphql │ └── schema.graphql ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── manifest.json │ └── robots.txt ├── schema.graphql ├── src │ ├── App.css │ ├── App.js │ ├── AuthToken.jsx │ ├── GraphQLData.js │ ├── NavBar.css │ ├── NavBar.js │ ├── PrivateRoute.js │ ├── Profile.css │ ├── Profile.js │ ├── QueryHistory.jsx │ ├── QueryStore.jsx │ ├── TodoApp.js │ ├── TodoFooter.js │ ├── TodoItem.js │ ├── Utils.js │ ├── config.json │ ├── defs.js │ ├── history.js │ ├── index.js │ ├── react-auth0-spa.js │ ├── setupTests.js │ └── slash_endpoint.js ├── todo-1.png ├── todo-2.png ├── todo-graph-2.png └── todo-graph.png ├── todo-app ├── .gitignore ├── README.md ├── babel.config.js ├── package.json ├── public │ ├── favicon.ico │ └── index.html ├── schema.graphql ├── src │ ├── App.vue │ ├── assets │ │ └── logo.png │ ├── components │ │ └── TodoApp.vue │ └── main.js ├── todo-app-flutter │ ├── .gitignore │ ├── .metadata │ ├── README.md │ ├── android │ │ ├── .gitignore │ │ ├── app │ │ │ ├── build.gradle │ │ │ └── src │ │ │ │ ├── debug │ │ │ │ └── AndroidManifest.xml │ │ │ │ ├── main │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── kotlin │ │ │ │ │ └── io │ │ │ │ │ │ └── dgraph │ │ │ │ │ │ └── fluttertodoapp │ │ │ │ │ │ └── MainActivity.kt │ │ │ │ └── res │ │ │ │ │ ├── drawable │ │ │ │ │ └── launch_background.xml │ │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ └── values │ │ │ │ │ └── styles.xml │ │ │ │ └── profile │ │ │ │ └── AndroidManifest.xml │ │ ├── build.gradle │ │ ├── gradle.properties │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ └── gradle-wrapper.properties │ │ └── settings.gradle │ ├── ios │ │ ├── .gitignore │ │ ├── Flutter │ │ │ ├── AppFrameworkInfo.plist │ │ │ ├── Debug.xcconfig │ │ │ └── Release.xcconfig │ │ ├── Runner.xcodeproj │ │ │ ├── project.pbxproj │ │ │ ├── project.xcworkspace │ │ │ │ └── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ └── xcschemes │ │ │ │ └── Runner.xcscheme │ │ ├── Runner.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ └── Runner │ │ │ ├── AppDelegate.swift │ │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ │ └── LaunchImage.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ └── README.md │ │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ │ ├── Info.plist │ │ │ └── Runner-Bridging-Header.h │ ├── lib │ │ ├── graphQLdata.dart │ │ └── main.dart │ ├── pubspec.yaml │ ├── schema.graphql │ ├── todo-1.png │ ├── todo-2.png │ └── todo-graph.png ├── todo-app-react │ ├── README.md │ ├── package.json │ ├── public │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── manifest.json │ │ └── robots.txt │ ├── schema.graphql │ ├── src │ │ ├── GraphQLData.js │ │ ├── TodoApp.js │ │ ├── TodoFooter.js │ │ ├── TodoItem.js │ │ ├── Utils.js │ │ ├── defs.js │ │ ├── index.js │ │ ├── serviceWorker.js │ │ └── setupTests.js │ ├── todo-1.png │ ├── todo-2.png │ ├── todo-graph.png │ └── yarn.lock ├── todo-app-vue │ ├── .gitignore │ ├── README.md │ ├── babel.config.js │ ├── package.json │ ├── public │ │ ├── favicon.ico │ │ └── index.html │ ├── schema.graphql │ ├── src │ │ ├── GraphQLData.js │ │ ├── TodoApp.vue │ │ ├── TodoFooter.vue │ │ ├── TodoItem.vue │ │ ├── assets │ │ │ └── logo.png │ │ └── main.js │ ├── todo-1.png │ ├── todo-2.png │ ├── todo-graph.png │ └── yarn.lock ├── todo-nextjs-ssr │ ├── .gitignore │ ├── README.md │ ├── components │ │ └── TodoList.js │ ├── next.config.js │ ├── package-lock.json │ ├── package.json │ ├── pages │ │ └── index.js │ ├── public │ │ ├── diggy.png │ │ ├── favicon.ico │ │ └── vercel.svg │ ├── schema.graphql │ └── yarn.lock └── yarn.lock ├── todo-react-firebase ├── .env ├── .gitignore ├── README.md ├── functions │ ├── .eslintrc.json │ ├── .gitignore │ ├── index.js │ ├── package-lock.json │ └── package.json ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── manifest.json │ └── robots.txt ├── schema.graphql ├── src │ ├── App.js │ ├── Auth.js │ ├── GraphQLData.js │ ├── Login.js │ ├── NavBar.css │ ├── NavBar.js │ ├── PrivateRoute.js │ ├── Profile.css │ ├── Profile.js │ ├── SignUp.js │ ├── TodoApp.js │ ├── TodoFooter.js │ ├── TodoItem.js │ ├── Utils.js │ ├── base.js │ ├── config.json │ ├── defs.js │ ├── history.js │ ├── index.js │ └── setupTests.js ├── todo-1.png ├── todo-2.png └── todo-graph.png └── twitter-app ├── README.md ├── schema.graphql └── seeder ├── go.mod ├── go.sum └── main.go /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: 'Close stale issues and PRs' 2 | on: 3 | schedule: 4 | - cron: '30 1 * * *' 5 | 6 | permissions: 7 | issues: write 8 | pull-requests: write 9 | 10 | jobs: 11 | stale: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/stale@v9 15 | with: 16 | stale-issue-message: 'This issue has been stale for 60 days and will be closed automatically in 7 days. Comment to keep it open.' 17 | stale-pr-message: 'This PR has been stale for 60 days and will be closed automatically in 7 days. Comment to keep it open.' 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | *.code-workspace 4 | donors-app/yarn.lock 5 | -------------------------------------------------------------------------------- /bin/bd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | if [ -z "$PROJECT" -o -z "$REACT_APP_GRAPHQL_ENDPOINT" ]; then 4 | echo "PROJECT=project REACT_APP_GRAPHQL_ENDPOINT=http://foo/graphql Usage $0" 5 | exit -1 6 | fi 7 | 8 | if [ "$PROJECT" == "noop" ]; then 9 | echo "Nothing to do" 10 | exit 0 11 | fi 12 | 13 | cd $PROJECT 14 | npm install 15 | NODE_ENV=production npm run build 16 | -------------------------------------------------------------------------------- /blog-post-app/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw? 22 | -------------------------------------------------------------------------------- /blog-post-app/README.md: -------------------------------------------------------------------------------- 1 | # blog-post-app 2 | 3 | ## Project setup 4 | ``` 5 | yarn install 6 | ``` 7 | 8 | ### Compiles and hot-reloads for development 9 | ``` 10 | yarn run serve 11 | ``` 12 | 13 | ### Compiles and minifies for production 14 | ``` 15 | yarn run build 16 | ``` 17 | 18 | ### Run your tests 19 | ``` 20 | yarn run test 21 | ``` 22 | 23 | ### Lints and fixes files 24 | ``` 25 | yarn run lint 26 | ``` 27 | 28 | ### Customize configuration 29 | See [Configuration Reference](https://cli.vuejs.org/config/). 30 | -------------------------------------------------------------------------------- /blog-post-app/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /blog-post-app/blog-post-react/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /blog-post-app/blog-post-react/blog-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/blog-post-app/blog-post-react/blog-1.png -------------------------------------------------------------------------------- /blog-post-app/blog-post-react/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Dgraph GraphQL Demo 10 | 11 | 12 | 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /blog-post-app/blog-post-react/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "Dgraph GraphQL Demo", 3 | "name": "Dgraph GraphQL Demo", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "theme_color": "#000000", 7 | "background_color": "#ffffff" 8 | } 9 | -------------------------------------------------------------------------------- /blog-post-app/blog-post-react/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | -------------------------------------------------------------------------------- /blog-post-app/blog-post-react/schema.graphql: -------------------------------------------------------------------------------- 1 | type Author { 2 | id: ID! 3 | name: String! @search(by: [hash, trigram]) 4 | dob: DateTime @search 5 | posts: [Post!] @hasInverse(field: author) 6 | } 7 | type Post { 8 | postID: ID! 9 | title: String! @search(by: [term, fulltext]) 10 | text: String @search(by: [fulltext]) 11 | tags: [String] @search(by: [exact]) 12 | topic: String @search(by: [exact]) 13 | numLikes: Int @search 14 | isPublished: Boolean @search 15 | author: Author! @hasInverse(field: posts) 16 | } 17 | -------------------------------------------------------------------------------- /blog-post-app/blog-post-react/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/blog-post-app/blog-post-react/screenshot.png -------------------------------------------------------------------------------- /blog-post-app/blog-post-react/src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom"; 3 | import App from "./App"; 4 | 5 | it("renders without crashing", () => { 6 | const div = document.createElement("div"); 7 | ReactDOM.render(, div); 8 | ReactDOM.unmountComponentAtNode(div); 9 | }); 10 | -------------------------------------------------------------------------------- /blog-post-app/blog-post-react/src/components/App.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | import PostList from "./PostList"; 4 | import Header from "./Header"; 5 | import PostView from "./ViewPost"; 6 | import CreatePost from "./CreatePost"; 7 | import { Switch, Route } from "react-router-dom"; 8 | import EditPost from "./EditPost"; 9 | 10 | export default function App() { 11 | return ( 12 |
13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | ); 23 | } 24 | -------------------------------------------------------------------------------- /blog-post-app/blog-post-react/src/components/Post.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { useHistory } from "react-router-dom" 3 | 4 | export default function Post({ post }) { 5 | const history = useHistory(); 6 | const viewPost = (postID) => { 7 | history.push({ 8 | pathname: '/view', 9 | search: `?postID=${postID}` 10 | }) 11 | } 12 | return ( 13 |
14 |
viewPost(post.postID)}> 15 |
Title: {post.title}
16 |
17 | by {post.author.name} 18 |
19 |
20 |
21 | ); 22 | } 23 | -------------------------------------------------------------------------------- /blog-post-app/blog-post-react/src/styles/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 4 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 12 | monospace; 13 | } 14 | 15 | .navbar-direction { 16 | flex-direction: row-reverse; 17 | } 18 | 19 | .card-pointer { 20 | cursor: pointer; 21 | } 22 | 23 | .delete-post { 24 | float: right; 25 | cursor: pointer; 26 | } 27 | 28 | .edit-post { 29 | float: right; 30 | margin-right: 5px; 31 | cursor: pointer; 32 | } 33 | 34 | .text-post { 35 | white-space: pre-wrap; 36 | margin-bottom: 10px; 37 | } 38 | 39 | .tagsset-post { 40 | float: right; 41 | } 42 | 43 | .tag-post { 44 | margin: 2px; 45 | } -------------------------------------------------------------------------------- /blog-post-app/blog-post-vue/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw? 22 | -------------------------------------------------------------------------------- /blog-post-app/blog-post-vue/README.md: -------------------------------------------------------------------------------- 1 | # blog-post-app 2 | 3 | ## Project setup 4 | ``` 5 | yarn install 6 | ``` 7 | 8 | ### Compiles and hot-reloads for development 9 | ``` 10 | yarn run serve 11 | ``` 12 | 13 | ### Compiles and minifies for production 14 | ``` 15 | yarn run build 16 | ``` 17 | 18 | ### Run your tests 19 | ``` 20 | yarn run test 21 | ``` 22 | 23 | ### Lints and fixes files 24 | ``` 25 | yarn run lint 26 | ``` 27 | 28 | ### Customize configuration 29 | See [Configuration Reference](https://cli.vuejs.org/config/). 30 | -------------------------------------------------------------------------------- /blog-post-app/blog-post-vue/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /blog-post-app/blog-post-vue/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/blog-post-app/blog-post-vue/public/favicon.ico -------------------------------------------------------------------------------- /blog-post-app/blog-post-vue/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | <%= htmlWebpackPlugin.options.title %> 10 | 11 | 12 | 15 |
16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /blog-post-app/blog-post-vue/schema.graphql: -------------------------------------------------------------------------------- 1 | type Author { 2 | id: ID! 3 | name: String! @search(by: [hash, trigram]) 4 | dob: DateTime @search 5 | posts: [Post!] @hasInverse(field: author) 6 | } 7 | type Post { 8 | postID: ID! 9 | title: String! @search(by: [term, fulltext]) 10 | text: String @search(by: [fulltext]) 11 | tags: [String] @search(by: [exact]) 12 | topic: String @search(by: [exact]) 13 | numLikes: Int @search 14 | isPublished: Boolean @search 15 | author: Author! @hasInverse(field: posts) 16 | } 17 | -------------------------------------------------------------------------------- /blog-post-app/blog-post-vue/src/App.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 20 | -------------------------------------------------------------------------------- /blog-post-app/blog-post-vue/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/blog-post-app/blog-post-vue/src/assets/logo.png -------------------------------------------------------------------------------- /blog-post-app/blog-post-vue/src/components/Post.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 30 | -------------------------------------------------------------------------------- /blog-post-app/blog-post-vue/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import App from "./App.vue"; 3 | import "bootstrap/dist/css/bootstrap.css"; 4 | import "../static/style.css"; 5 | import VueApollo from "vue-apollo"; 6 | import router from "./router"; 7 | 8 | import ApolloClient from "apollo-boost"; 9 | import { InMemoryCache } from "apollo-boost"; 10 | 11 | Vue.use(VueApollo); 12 | 13 | Vue.config.productionTip = false; 14 | 15 | const client = new ApolloClient({ 16 | uri: "http://localhost:8080/graphql", 17 | cache: new InMemoryCache(), 18 | }); 19 | 20 | const apolloProvider = new VueApollo({ 21 | defaultClient: client, 22 | }); 23 | 24 | new Vue({ 25 | router, 26 | apolloProvider, 27 | render: (h) => h(App), 28 | }).$mount("#app"); 29 | -------------------------------------------------------------------------------- /blog-post-app/blog-post-vue/src/router.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import Router from "vue-router"; 3 | import PostList from "./views/PostList"; 4 | import ViewPost from "./views/ViewPost"; 5 | import CreatePost from "./views/CreatePost"; 6 | import EditPost from "./views/EditPost"; 7 | 8 | Vue.use(Router); 9 | 10 | const router = new Router({ 11 | mode: "history", 12 | routes: [ 13 | { 14 | path: "/", 15 | name: "posts", 16 | component: PostList, 17 | }, 18 | { 19 | path: "/view", 20 | name: "view", 21 | component: ViewPost, 22 | }, 23 | { 24 | path: "/create", 25 | name: "create", 26 | component: CreatePost, 27 | }, 28 | { 29 | path: "/edit", 30 | name: "edit", 31 | component: EditPost, 32 | }, 33 | ], 34 | }); 35 | 36 | export default router; 37 | -------------------------------------------------------------------------------- /blog-post-app/blog-post-vue/static/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 4 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 12 | monospace; 13 | } 14 | 15 | .navbar-direction { 16 | flex-direction: row-reverse; 17 | } 18 | 19 | .card-pointer { 20 | cursor: pointer; 21 | } 22 | 23 | .delete-post { 24 | float: right; 25 | cursor: pointer; 26 | } 27 | 28 | .edit-post { 29 | float: right; 30 | margin-right: 5px; 31 | cursor: pointer; 32 | } 33 | 34 | .text-post { 35 | white-space: pre-wrap; 36 | margin-bottom: 10px; 37 | } 38 | 39 | .tagsset-post { 40 | float: right; 41 | } 42 | 43 | .tag-post { 44 | margin: 2px; 45 | } 46 | -------------------------------------------------------------------------------- /blog-post-app/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/blog-post-app/public/favicon.ico -------------------------------------------------------------------------------- /blog-post-app/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | <%= htmlWebpackPlugin.options.title %> 10 | 11 | 12 | 15 |
16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /blog-post-app/schema.graphql: -------------------------------------------------------------------------------- 1 | type Author { 2 | id: ID! 3 | name: String! @search(by: [hash, trigram]) 4 | dob: DateTime @search 5 | posts: [Post!] @hasInverse(field: author) 6 | } 7 | type Post { 8 | postID: ID! 9 | title: String! @search(by: [term, fulltext]) 10 | text: String @search(by: [fulltext]) 11 | tags: [String] @search(by: [exact]) 12 | topic: String @search(by: [exact]) 13 | numLikes: Int @search 14 | isPublished: Boolean @search 15 | author: Author! @hasInverse(field: posts) 16 | } 17 | -------------------------------------------------------------------------------- /blog-post-app/src/App.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 20 | -------------------------------------------------------------------------------- /blog-post-app/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/blog-post-app/src/assets/logo.png -------------------------------------------------------------------------------- /blog-post-app/src/components/Post.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 31 | -------------------------------------------------------------------------------- /blog-post-app/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import App from "./App.vue"; 3 | import "bootstrap/dist/css/bootstrap.css"; 4 | import "../static/style.css"; 5 | import VueApollo from "vue-apollo"; 6 | import router from "./router"; 7 | 8 | import ApolloClient from "apollo-boost"; 9 | import { InMemoryCache } from "apollo-boost"; 10 | 11 | Vue.use(VueApollo); 12 | 13 | Vue.config.productionTip = false; 14 | 15 | // 3 16 | const client = new ApolloClient({ 17 | uri: "http://localhost:8080/graphql", 18 | cache: new InMemoryCache(), 19 | }); 20 | 21 | const apolloProvider = new VueApollo({ 22 | defaultClient: client, 23 | }); 24 | 25 | new Vue({ 26 | router, 27 | apolloProvider, 28 | render: (h) => h(App), 29 | }).$mount("#app"); 30 | -------------------------------------------------------------------------------- /blog-post-app/src/router.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import Router from "vue-router"; 3 | // import Hello from "./components/HelloWorld.vue" 4 | import PostList from "./views/PostList"; 5 | import ViewPost from "./views/ViewPost"; 6 | import CreatePost from "./views/CreatePost"; 7 | import EditPost from "./views/EditPost"; 8 | 9 | Vue.use(Router); 10 | 11 | const router = new Router({ 12 | mode: "history", 13 | routes: [ 14 | { 15 | path: "/", 16 | name: "posts", 17 | component: PostList, 18 | }, 19 | { 20 | path: "/view", 21 | name: "view", 22 | component: ViewPost, 23 | }, 24 | { 25 | path: "/create", 26 | name: "create", 27 | component: CreatePost, 28 | }, 29 | { 30 | path: "/edit", 31 | name: "edit", 32 | component: EditPost, 33 | }, 34 | ], 35 | }); 36 | 37 | export default router; 38 | -------------------------------------------------------------------------------- /blog-post-app/static/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 4 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 12 | monospace; 13 | } 14 | 15 | .navbar-direction { 16 | flex-direction: row-reverse; 17 | } 18 | 19 | .card-pointer { 20 | cursor: pointer; 21 | } 22 | 23 | .delete-post { 24 | float: right; 25 | cursor: pointer; 26 | } 27 | 28 | .edit-post { 29 | float: right; 30 | margin-right: 5px; 31 | cursor: pointer; 32 | } 33 | 34 | .text-post { 35 | white-space: pre-wrap; 36 | margin-bottom: 10px; 37 | } 38 | 39 | .tagsset-post { 40 | float: right; 41 | } 42 | 43 | .tag-post { 44 | margin: 2px; 45 | } 46 | -------------------------------------------------------------------------------- /charting/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | /.pnp 4 | .pnp.js 5 | 6 | # testing 7 | /coverage 8 | 9 | # production 10 | /build 11 | 12 | # misc 13 | .DS_Store 14 | .env 15 | .env.local 16 | .env.development.local 17 | .env.test.local 18 | .env.production.local 19 | 20 | npm-debug.log* 21 | yarn-debug.log* 22 | yarn-error.log* 23 | -------------------------------------------------------------------------------- /charting/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/charting/public/favicon.ico -------------------------------------------------------------------------------- /charting/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/charting/public/logo192.png -------------------------------------------------------------------------------- /charting/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/charting/public/logo512.png -------------------------------------------------------------------------------- /charting/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /charting/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /charting/schema.graphql: -------------------------------------------------------------------------------- 1 | type Metric { 2 | name: String! @id 3 | readings: [Reading!] 4 | } 5 | 6 | type Collection { 7 | timestamp: DateTime! @search 8 | readings: [Reading!]! 9 | } 10 | 11 | type Reading { 12 | value: Float 13 | metric: Metric! @hasInverse(field: readings) 14 | collection: Collection! @hasInverse(field: readings) 15 | } 16 | -------------------------------------------------------------------------------- /charting/screenshots/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/charting/screenshots/home.png -------------------------------------------------------------------------------- /charting/screenshots/metrics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/charting/screenshots/metrics.png -------------------------------------------------------------------------------- /charting/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /charting/src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | const { getByText } = render(); 7 | const linkElement = getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /charting/src/apollo-client.js: -------------------------------------------------------------------------------- 1 | import { ApolloClient, InMemoryCache } from '@apollo/client'; 2 | 3 | const client = new ApolloClient({ 4 | uri: process.env.REACT_APP_GRAPHQL_ENDPOINT || "https://beneficial-baseball-9463.us-west-2.aws.cloud.dgraph.io/graphql", 5 | cache: new InMemoryCache(), 6 | }); 7 | 8 | export default client; 9 | -------------------------------------------------------------------------------- /charting/src/assets/images/imageThree.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/charting/src/assets/images/imageThree.jpeg -------------------------------------------------------------------------------- /charting/src/assets/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/charting/src/assets/images/logo.png -------------------------------------------------------------------------------- /charting/src/assets/images/search.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /charting/src/assets/images/user.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /charting/src/components/card.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { Card } from "@material-ui/core" 3 | import { makeStyles } from '@material-ui/core/styles'; 4 | 5 | const useStyles = makeStyles(theme => ({ 6 | centeredCard: { 7 | padding: 20, 8 | textAlign: "center", 9 | } 10 | })) 11 | 12 | export function CenteredCard(props) { 13 | const {centeredCard} = useStyles() 14 | return 15 | } 16 | -------------------------------------------------------------------------------- /charting/src/components/formField.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Grid } from "@material-ui/core"; 3 | import TextField from "@material-ui/core/TextField"; 4 | 5 | const FormField = ({ type, label, name, required, defaultValue }) => { 6 | return ( 7 | 8 | 18 | 19 | ); 20 | }; 21 | 22 | export default FormField; 23 | -------------------------------------------------------------------------------- /charting/src/components/search.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-use-before-define */ 2 | import React from 'react'; 3 | import TextField from '@material-ui/core/TextField'; 4 | import Autocomplete from '@material-ui/lab/Autocomplete'; 5 | 6 | export function Search({ data, label, onChange }) { 7 | return ( 8 |
9 | option.name)} 14 | renderInput={(params) => ( 15 | 16 | )} 17 | /> 18 |
19 | ); 20 | } -------------------------------------------------------------------------------- /charting/src/components/sidebar/sidebar.style.js: -------------------------------------------------------------------------------- 1 | import { makeStyles } from '@material-ui/core/styles'; 2 | 3 | const drawerWidth = 240; 4 | 5 | const useStyles = makeStyles((theme) => ({ 6 | drawer: { 7 | width: drawerWidth, 8 | // flexShrink: 0, 9 | }, 10 | drawerPaper: { 11 | width: drawerWidth, 12 | }, 13 | drawerHeader: { 14 | display: "flex", 15 | alignItems: "center", 16 | padding: theme.spacing(0, 1), 17 | // necessary for content to be below app bar 18 | ...theme.mixins.toolbar, 19 | justifyContent: "flex-end", 20 | }, 21 | logo: { 22 | display: "flex", 23 | padding: theme.spacing(0, 1), 24 | ...theme.mixins.toolbar, 25 | justifyContent: "center", 26 | }, 27 | nested: { 28 | paddingLeft: theme.spacing(4), 29 | }, 30 | hideSidebar: { 31 | marginTop: "100%", 32 | }, 33 | })); 34 | 35 | export default useStyles; -------------------------------------------------------------------------------- /charting/src/components/ugly-button.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { makeStyles } from '@material-ui/core/styles'; 3 | import { Button } from '@material-ui/core'; 4 | 5 | const useStyles = makeStyles(theme => ({ 6 | root: { 7 | margin: "4px 12px", 8 | backgroundColor: theme.palette.primary.main, 9 | color: "white", 10 | '&:hover': { 11 | backgroundColor: theme.palette.secondary.main, 12 | } 13 | } 14 | })) 15 | 16 | export default function UglyButton(props) { 17 | const { root } = useStyles(); 18 | return 19 | ); 20 | }; 21 | 22 | export default LoginButton; -------------------------------------------------------------------------------- /dev-jokes/src/components/auth/logoutButton.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { useAuth0 } from "@auth0/auth0-react"; 3 | 4 | import Button from '@material-ui/core/Button'; 5 | import ExitToAppIcon from '@material-ui/icons/ExitToApp'; 6 | 7 | const LogoutButton = () => { 8 | const { logout } = useAuth0(); 9 | return ( 10 | 18 | ); 19 | }; 20 | 21 | export default LogoutButton; -------------------------------------------------------------------------------- /dev-jokes/src/components/auth/signupButton.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { useAuth0 } from "@auth0/auth0-react"; 3 | import Button from '@material-ui/core/Button'; 4 | 5 | const SignupButton = () => { 6 | const { loginWithRedirect } = useAuth0(); 7 | return ( 8 | 20 | ); 21 | }; 22 | 23 | export default SignupButton; -------------------------------------------------------------------------------- /dev-jokes/src/components/loading.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { CircularProgress } from "@material-ui/core"; 3 | 4 | const Loading = () => ( 5 |
6 | 7 |
8 | ); 9 | 10 | export default Loading; 11 | -------------------------------------------------------------------------------- /dev-jokes/src/components/privateRoute.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Route } from "react-router-dom"; 3 | import { withAuthenticationRequired } from "@auth0/auth0-react"; 4 | import Loading from "./loading"; 5 | 6 | const PrivateRoute = ({ component, ...args }) => ( 7 | , 10 | })} 11 | {...args} 12 | /> 13 | ); 14 | 15 | export default PrivateRoute; -------------------------------------------------------------------------------- /dev-jokes/src/components/sidebar/sidebar.style.js: -------------------------------------------------------------------------------- 1 | import { makeStyles } from '@material-ui/core/styles'; 2 | 3 | const drawerWidth = 180; 4 | const drawerWidthSm = 60; 5 | 6 | const useStyles = makeStyles((theme) => ({ 7 | drawer: { 8 | width: drawerWidth, 9 | flexShrink:0, 10 | [theme.breakpoints.down('xs')]: { 11 | width: drawerWidthSm, 12 | }, 13 | }, 14 | drawerPaper: { 15 | width: drawerWidth, 16 | flexShrink:0, 17 | [theme.breakpoints.down('xs')]: { 18 | width: drawerWidthSm, 19 | }, 20 | }, 21 | drawerHeader: { 22 | display: "flex", 23 | alignItems: "center", 24 | padding: theme.spacing(0, 1), 25 | // necessary for content to be below app bar 26 | ...theme.mixins.toolbar, 27 | justifyContent: "flex-end", 28 | }, 29 | logo: { 30 | display: "flex", 31 | padding: theme.spacing(0, 1), 32 | ...theme.mixins.toolbar, 33 | justifyContent: "center", 34 | }, 35 | nested: { 36 | paddingLeft: theme.spacing(4), 37 | }, 38 | hideSidebar: { 39 | marginTop: "100%", 40 | }, 41 | })); 42 | 43 | export default useStyles; -------------------------------------------------------------------------------- /dev-jokes/src/config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | "REACT_APP_AUTH0_DOMAIN": "watchu.auth0.com", 3 | "REACT_APP_AUTH0_CLIENT_ID": "iJ55DI6OVtl57W79uGAOLQ5mCMDNyvaY", 4 | "REACT_APP_GRAPHQL_ENDPOINT": "https://encouraging-form-8164.us-west-2.aws.cloud.dgraph.io/graphql", 5 | "AWS_ENDPOINT": "https://agfpqpmjc2.execute-api.us-east-1.amazonaws.com/getSignedURL" 6 | } 7 | -------------------------------------------------------------------------------- /dev-jokes/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | 4 | import { createMuiTheme, ThemeProvider } from '@material-ui/core/styles'; 5 | 6 | import './index.css'; 7 | import App from './App'; 8 | import themes from './theme'; 9 | 10 | import Auth0ProviderWithHistory from './utils/auth0-provider-with-history'; 11 | 12 | const theme = createMuiTheme(themes); 13 | 14 | ReactDOM.render( 15 | 16 | 17 | 18 | 19 | , 20 | document.getElementById('root') 21 | ); 22 | 23 | -------------------------------------------------------------------------------- /dev-jokes/src/pages/not-found.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import {Typography} from '@material-ui/core'; 3 | import Content from '../components/content'; 4 | 5 | const NotFound = () => { 6 | return <> 7 | 8 | 9 | That page wasn't found. 10 | 11 | 12 | 13 | } 14 | 15 | export default NotFound; 16 | -------------------------------------------------------------------------------- /dev-jokes/src/utils/apollo-client.js: -------------------------------------------------------------------------------- 1 | import { ApolloClient, InMemoryCache } from '@apollo/client'; 2 | import { createHttpLink } from "apollo-link-http"; 3 | import { setContext } from "apollo-link-context"; 4 | import config from "../config" 5 | 6 | const createApolloClient = (token) => { 7 | const httpLink = createHttpLink({ 8 | uri: process.env.REACT_APP_GRAPHQL_ENDPOINT || config["REACT_APP_GRAPHQL_ENDPOINT"], 9 | options: { 10 | reconnect: true, 11 | }, 12 | }); 13 | 14 | const authLink = setContext((_, { headers }) => { 15 | // return the headers to the context so httpLink can read them 16 | return { 17 | headers: { 18 | ...headers, 19 | "X-Auth-Token": token, 20 | }, 21 | }; 22 | }); 23 | 24 | return new ApolloClient({ 25 | link: authLink.concat(httpLink), 26 | cache: new InMemoryCache() 27 | }); 28 | } 29 | 30 | export default createApolloClient; 31 | -------------------------------------------------------------------------------- /dev-jokes/src/utils/auth0-provider-with-history.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Auth0Provider } from "@auth0/auth0-react"; 3 | import config from "../config" 4 | 5 | const Auth0ProviderWithHistory = ({ children }) => { 6 | const domain = process.env.REACT_APP_AUTH0_DOMAIN || config["REACT_APP_AUTH0_DOMAIN"]; 7 | const clientId = process.env.REACT_APP_AUTH0_CLIENT_ID || config["REACT_APP_AUTH0_CLIENT_ID"]; 8 | 9 | return ( 10 | 15 | {children} 16 | 17 | ); 18 | }; 19 | 20 | export default Auth0ProviderWithHistory; -------------------------------------------------------------------------------- /dev-jokes/src/utils/history.js: -------------------------------------------------------------------------------- 1 | import { createBrowserHistory } from "history"; 2 | 3 | const history = createBrowserHistory(); 4 | 5 | export default history; 6 | -------------------------------------------------------------------------------- /dev-jokes/src/utils/imperativeQuery.js: -------------------------------------------------------------------------------- 1 | import { useQuery } from "@apollo/react-hooks"; 2 | 3 | const useImperativeQuery = (query) => { 4 | const { refetch } = useQuery(query, {skip:true}); 5 | const imperativelyCallQuery = (variables) => { 6 | return refetch(variables); 7 | }; 8 | return imperativelyCallQuery; 9 | }; 10 | 11 | export default useImperativeQuery; -------------------------------------------------------------------------------- /dgraph-lambda/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules -------------------------------------------------------------------------------- /dgraph-lambda/README.md: -------------------------------------------------------------------------------- 1 | ## Slash GraphQL Lambda example 2 | 3 | Install the [Slash GraphQL CLI](https://www.npmjs.com/package/slash-graphql) 4 | ``` 5 | npm install -g slash-graphql 6 | ``` 7 | 8 | Replace the `url` in the `config` object in the `package.json` file with your Slash GraphQL endpoint. 9 | 10 | - `slash-login` - Login Slash GraphQL 11 | - `push-schema` - Update schema on Slash GraphQL 12 | - `push-lambda` - Generate bundle for script & update lambda on Slash GraphQL 13 | - `slash-drop-data` - Drop all data and leave the schema on Slash GraphQL 14 | -------------------------------------------------------------------------------- /dgraph-lambda/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dgraph-lambda", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "config": { 7 | "url": "YOUR-SLASH-GRAPHQL-ENDPOINT" 8 | }, 9 | "scripts": { 10 | "slash-login": "slash-graphql login", 11 | "push-schema": "slash-graphql update-schema -e $npm_package_config_url schema.graphql", 12 | "slash-update-lambda": "slash-graphql update-lambda -e $npm_package_config_url -f=dist/main.js", 13 | "push-lambda": "npx webpack --target=webworker && npm run slash-update-lambda", 14 | "slash-drop-data": "slash-graphql drop -e $npm_package_config_url -d" 15 | }, 16 | "author": "", 17 | "license": "ISC", 18 | "dependencies": { 19 | "chalk": "^4.1.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /dgraph-lambda/schema.graphql: -------------------------------------------------------------------------------- 1 | type Player { 2 | id: ID! 3 | name: String! @search(by: [fulltext]) 4 | position: String! @search 5 | pace: Int! 6 | shooting: Int! 7 | passing: Int! 8 | dribbling: Int! 9 | defending: Int! 10 | physical: Int! 11 | overall: Int @lambda 12 | club: String 13 | country: String 14 | } 15 | 16 | type Transfer { 17 | id: ID! 18 | player: String! 19 | currentclub: String! 20 | } 21 | 22 | type Query { 23 | topForwardPlayers: [Player] @lambda 24 | } 25 | 26 | type Mutation { 27 | sendTransferRequest(player: String!, currentclub: String!): ID! @lambda 28 | } 29 | -------------------------------------------------------------------------------- /donors-app/.graphqlrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema" : "https://green-bird.us-east-1.aws.cloud.dgraph.io/graphql", 3 | "documents":"src/**/*.ts" 4 | } -------------------------------------------------------------------------------- /donors-app/codegen.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { CodegenConfig } from '@graphql-codegen/cli'; 3 | 4 | const config: CodegenConfig = { 5 | overwrite: true, 6 | schema: "https://green-bird.us-east-1.aws.cloud.dgraph.io/graphql", 7 | documents: "src/**/*.ts", 8 | generates: { 9 | "./src/gql/": { 10 | preset: "client", 11 | presetConfig: { 12 | fragmentMasking: false 13 | }, 14 | plugins: [] 15 | } 16 | } 17 | }; 18 | 19 | export default config; 20 | -------------------------------------------------------------------------------- /donors-app/public/diggy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/donors-app/public/diggy.png -------------------------------------------------------------------------------- /donors-app/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/donors-app/public/favicon.ico -------------------------------------------------------------------------------- /donors-app/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/donors-app/public/logo192.png -------------------------------------------------------------------------------- /donors-app/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/donors-app/public/logo512.png -------------------------------------------------------------------------------- /donors-app/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /donors-app/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /donors-app/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /donors-app/src/App.test.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render, screen } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | render(); 7 | const linkElement = screen.getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /donors-app/src/components/operations.ts: -------------------------------------------------------------------------------- 1 | import { graphql } from "../gql"; 2 | 3 | export const SchoolFragment = graphql(` 4 | fragment SchoolItem on School { 5 | id 6 | name 7 | type 8 | projects { 9 | title 10 | } 11 | } 12 | `) 13 | 14 | 15 | export const SchoolslByTermDocument = graphql(` 16 | query schoolsByTerm($term: String!) { 17 | querySchool (filter: {name: {allofterms: $term}}, first: 10) { 18 | ...SchoolItem 19 | } 20 | } 21 | `) 22 | 23 | -------------------------------------------------------------------------------- /donors-app/src/gql/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./gql"; -------------------------------------------------------------------------------- /donors-app/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /donors-app/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom/client'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | import 'bootstrap/dist/css/bootstrap.min.css'; 7 | import {createClient, Provider} from 'urql'; 8 | 9 | const root = ReactDOM.createRoot( 10 | document.getElementById('root') as HTMLElement 11 | ); 12 | 13 | const client = createClient({ 14 | url: "https://green-bird.us-east-1.aws.cloud.dgraph.io/graphql" 15 | }) 16 | root.render( 17 | 18 | 19 | 20 | 21 | 22 | ); 23 | 24 | // If you want to start measuring performance in your app, pass a function 25 | // to log results (for example: reportWebVitals(console.log)) 26 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 27 | reportWebVitals(); 28 | -------------------------------------------------------------------------------- /donors-app/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /donors-app/src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from 'web-vitals'; 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry); 7 | getFID(onPerfEntry); 8 | getFCP(onPerfEntry); 9 | getLCP(onPerfEntry); 10 | getTTFB(onPerfEntry); 11 | }); 12 | } 13 | }; 14 | 15 | export default reportWebVitals; 16 | -------------------------------------------------------------------------------- /donors-app/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /donors-app/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /instaclone/.env: -------------------------------------------------------------------------------- 1 | REACT_APP_BACKEND_ENDPOINT=""<>"" 2 | REACT_APP_AUTH0_DOMAIN="<>" 3 | REACT_APP_AUTH0_CLIENT_ID="<>" -------------------------------------------------------------------------------- /instaclone/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /instaclone/README.md: -------------------------------------------------------------------------------- 1 | # InstaClone 2 | 3 | Sample app accompanying a series of blog posts showing how to model an Instagram clone using GraphQL and Dgraph. 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `npm run build` 18 | 19 | Builds the app for production to the `build` folder.\ 20 | It correctly bundles React in production mode and optimizes the build for the best performance. 21 | 22 | The build is minified and the filenames include the hashes.\ 23 | Your app is ready to be deployed! -------------------------------------------------------------------------------- /instaclone/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/instaclone/public/favicon.ico -------------------------------------------------------------------------------- /instaclone/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/instaclone/public/logo192.png -------------------------------------------------------------------------------- /instaclone/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/instaclone/public/logo512.png -------------------------------------------------------------------------------- /instaclone/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /instaclone/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /instaclone/src/App.js: -------------------------------------------------------------------------------- 1 | import NavBar from "./Components/Nav"; 2 | import Feed from "./Components/Feed"; 3 | import { Box, Grommet } from "grommet"; 4 | 5 | const theme = { 6 | global: { 7 | font: { 8 | family: "Roboto", 9 | size: "18px", 10 | height: "20px", 11 | }, 12 | }, 13 | }; 14 | 15 | const App = () => ( 16 | 17 | 18 | 19 | 20 | 21 | 22 | ); 23 | 24 | export default App; 25 | -------------------------------------------------------------------------------- /instaclone/src/Components/AuthButtons.js: -------------------------------------------------------------------------------- 1 | import LogInButton from "./LogInButton"; 2 | import LogOutButton from "./LogOutButton"; 3 | import { useAuth0 } from "@auth0/auth0-react"; 4 | 5 | const AuthButton = () => { 6 | const { isAuthenticated } = useAuth0(); 7 | 8 | return isAuthenticated ? : ; 9 | }; 10 | 11 | export default AuthButton; -------------------------------------------------------------------------------- /instaclone/src/Components/GenericButton.js: -------------------------------------------------------------------------------- 1 | import { Button } from "grommet"; 2 | 3 | export const GenericButton = (props) => ; 4 | -------------------------------------------------------------------------------- /instaclone/src/Components/LogInButton.js: -------------------------------------------------------------------------------- 1 | import { useAuth0 } from "@auth0/auth0-react"; 2 | import { GenericButton } from "./GenericButton"; 3 | 4 | const LogInButton = () => { 5 | const { loginWithRedirect } = useAuth0(); 6 | 7 | return ( 8 | 16 | ); 17 | }; 18 | 19 | export default LogInButton; 20 | -------------------------------------------------------------------------------- /instaclone/src/Components/LogOutButton.js: -------------------------------------------------------------------------------- 1 | import { GenericButton } from "./GenericButton"; 2 | import { useAuth0 } from "@auth0/auth0-react"; 3 | 4 | const LogOutButton = () => { 5 | const { logout } = useAuth0(); 6 | 7 | return ( 8 | 14 | logout({ 15 | returnTo: window.location.origin, 16 | }) 17 | } 18 | /> 19 | ); 20 | }; 21 | 22 | export default LogOutButton; 23 | -------------------------------------------------------------------------------- /instaclone/src/Components/Nav.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Box, Text } from "grommet"; 3 | import { Instagram } from "grommet-icons"; 4 | import AuthButton from "./AuthButtons"; 5 | 6 | const NavBar = () => ( 7 | 17 | 18 | 19 | InstaClone 20 | 21 | 22 | 30 | 31 | 32 | 33 | ); 34 | 35 | export default NavBar; 36 | -------------------------------------------------------------------------------- /instaclone/src/GraphQL/Queries.js: -------------------------------------------------------------------------------- 1 | import { gql } from "@apollo/client"; 2 | 3 | export const QUERY_LOGGED_IN_USER = gql` 4 | subscription getUserInfo($userFilter: UserFilter!) { 5 | queryUser(filter: $userFilter) { 6 | email 7 | following { 8 | username 9 | avatarImageURL 10 | posts { 11 | id 12 | imageURL 13 | description 14 | likes 15 | postedBy { 16 | username 17 | avatarImageURL 18 | } 19 | } 20 | } 21 | } 22 | } 23 | `; -------------------------------------------------------------------------------- /instaclone/src/index.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom"; 3 | import { Auth0Provider } from "@auth0/auth0-react"; 4 | import ApolloWrapper from './Components/ApolloWrapper'; 5 | 6 | const domain = process.env.REACT_APP_AUTH0_DOMAIN; 7 | const clientId = process.env.REACT_APP_AUTH0_CLIENT_ID; 8 | 9 | ReactDOM.render( 10 | 15 | 16 | 17 | 18 | , 19 | document.getElementById("root") 20 | ); 21 | -------------------------------------------------------------------------------- /pokedex/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /pokedex/.prettierignore: -------------------------------------------------------------------------------- 1 | build 2 | coverage 3 | -------------------------------------------------------------------------------- /pokedex/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | trailingComma: 'es5', 3 | tabWidth: 2, 4 | semi: false, 5 | singleQuote: true, 6 | } 7 | -------------------------------------------------------------------------------- /pokedex/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/pokedex/public/favicon.ico -------------------------------------------------------------------------------- /pokedex/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/pokedex/public/logo192.png -------------------------------------------------------------------------------- /pokedex/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/pokedex/public/logo512.png -------------------------------------------------------------------------------- /pokedex/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "Pokédex", 3 | "name": "Pokédex", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /pokedex/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /pokedex/screen1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/pokedex/screen1.png -------------------------------------------------------------------------------- /pokedex/snippets/add-single-pokemon.graphql: -------------------------------------------------------------------------------- 1 | mutation AddPokemon { 2 | addPokemon( 3 | input: [ 4 | { 5 | id: 1 6 | name: "Bulbasaur" 7 | captured: false 8 | imgUrl: "http://img.pokemondb.net/artwork/bulbasaur.jpg" 9 | pokemonTypes: [Grass, Poison] 10 | } 11 | ] 12 | ) { 13 | pokemon { 14 | id 15 | name 16 | captured 17 | imgUrl 18 | pokemonTypes 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /pokedex/snippets/delete-single-pokemon.graphql: -------------------------------------------------------------------------------- 1 | mutation DeletePokemon { 2 | deletePokemon(filter: { name: { alloftext: "Bulbasaur" } }) { 3 | pokemon { 4 | name 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /pokedex/snippets/query-pokemon-by-captured.graphql: -------------------------------------------------------------------------------- 1 | query GetAllCapturedPokemon { 2 | queryPokemon(filter: { captured: true }) { 3 | id 4 | name 5 | captured 6 | imgUrl 7 | pokemonTypes 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /pokedex/snippets/query-pokemon-by-type-and-by-captured.graphql: -------------------------------------------------------------------------------- 1 | query GetAllCapturedGrassPokemon { 2 | queryPokemon(filter: { captured: true, pokemonTypes: { eq: [Grass] } }) { 3 | id 4 | name 5 | captured 6 | imgUrl 7 | pokemonTypes 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /pokedex/snippets/query-pokemon-by-type.graphql: -------------------------------------------------------------------------------- 1 | query GetAllGrassPokemon { 2 | queryPokemon(filter: { pokemonTypes: { eq: [Grass] } }) { 3 | id 4 | name 5 | captured 6 | imgUrl 7 | pokemonTypes 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /pokedex/snippets/query-pokemon-names.graphql: -------------------------------------------------------------------------------- 1 | query GetAllPokemonNames { 2 | queryPokemon { 3 | name 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /pokedex/snippets/query-pokemon.graphql: -------------------------------------------------------------------------------- 1 | query GetAllPokemon { 2 | queryPokemon { 3 | id 4 | name 5 | captured 6 | imgUrl 7 | pokemonTypes 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /pokedex/snippets/schema.graphql: -------------------------------------------------------------------------------- 1 | enum PokemonType { 2 | Bug 3 | Dark 4 | Dragon 5 | Electric 6 | Fairy 7 | Fighting 8 | Fire 9 | Flying 10 | Ghost 11 | Grass 12 | Ground 13 | Ice 14 | Normal 15 | Poison 16 | Psychic 17 | Rock 18 | Steel 19 | Water 20 | } 21 | 22 | type Pokemon { 23 | id: Int! @search 24 | name: String! @search(by: [fulltext]) 25 | captured: Boolean! @search 26 | imgUrl: String! 27 | pokemonTypes: [PokemonType!]! @search 28 | } 29 | -------------------------------------------------------------------------------- /pokedex/snippets/update-single-pokemon.graphql: -------------------------------------------------------------------------------- 1 | mutation UpdatePokemon { 2 | updatePokemon(input: { filter: { id: { eq: 1 } }, set: { captured: true } }) { 3 | pokemon { 4 | name 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /pokedex/src/index.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | margin: 0; 4 | padding: 0; 5 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 6 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 7 | sans-serif; 8 | -webkit-font-smoothing: antialiased; 9 | -moz-osx-font-smoothing: grayscale; 10 | background: #3b4cca; 11 | background: #ccc; 12 | background: #5db9ff; 13 | } 14 | 15 | html { 16 | font-size: 16px; 17 | } 18 | 19 | body { 20 | font-size: 100%; 21 | padding: 0 2rem 2rem 2rem; 22 | } 23 | 24 | * { 25 | box-sizing: border-box; 26 | } 27 | 28 | code { 29 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 30 | monospace; 31 | } 32 | -------------------------------------------------------------------------------- /pokedex/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactDOM from 'react-dom' 3 | import './index.css' 4 | import App from './App' 5 | import * as serviceWorker from './serviceWorker' 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root') 12 | ) 13 | 14 | // If you want your app to work offline and load faster, you can change 15 | // unregister() to register() below. Note this comes with some pitfalls. 16 | // Learn more about service workers: https://bit.ly/CRA-PWA 17 | serviceWorker.unregister() 18 | -------------------------------------------------------------------------------- /pokedex/src/pokemon-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/pokedex/src/pokemon-logo.png -------------------------------------------------------------------------------- /pokedex/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect' 6 | -------------------------------------------------------------------------------- /stackoverflow-app/apollo-dgraph/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | scripts/dgraph 3 | dist -------------------------------------------------------------------------------- /stackoverflow-app/apollo-dgraph/README.md: -------------------------------------------------------------------------------- 1 | ## Building a Dgraph+Apollo server 2 | 3 | That's Dgraph-GraphQL backend, with an Apollo server over the top that removes/hides some of the underlying GraphQL schema and adds some extra functionality. 4 | 5 | ## Start server 6 | ```sh 7 | npm run start:dev 8 | ``` 9 | 10 | To rebuild the types (e.g. if you edit the schema) 11 | ```sh 12 | npm run generate 13 | ``` -------------------------------------------------------------------------------- /stackoverflow-app/apollo-dgraph/codegen.yaml: -------------------------------------------------------------------------------- 1 | generates: 2 | src/types/gql.d.ts: 3 | schema: 4 | - src/schema/schema.graphql 5 | plugins: 6 | - typescript 7 | - typescript-resolvers 8 | config: 9 | useIndexSignature: true 10 | -------------------------------------------------------------------------------- /stackoverflow-app/apollo-dgraph/src/dgraph/dgraph.graphql: -------------------------------------------------------------------------------- 1 | type Author { 2 | username: String! @id 3 | email: String! 4 | dob: DateTime 5 | questions: [Question] @hasInverse(field: author) 6 | answers: [Answer] @hasInverse(field: author) 7 | } 8 | interface Post { 9 | id: ID! 10 | text: String! @search(by: [fulltext]) 11 | datePublished: DateTime @search 12 | likes: Int 13 | author: Author! 14 | comments: [Comment] @hasInverse(field: commentsOn) 15 | } 16 | type Question implements Post { 17 | title: String! @search(by: [term]) 18 | tags: [String] @search(by: [exact]) 19 | answers: [Answer] @hasInverse(field: inAnswerTo) 20 | } 21 | type Answer implements Post { 22 | inAnswerTo: Question! 23 | } 24 | type Comment implements Post { 25 | commentsOn: Post! 26 | } 27 | -------------------------------------------------------------------------------- /stackoverflow-app/apollo-dgraph/src/dgraph/index.ts: -------------------------------------------------------------------------------- 1 | import { 2 | makeRemoteExecutableSchema, 3 | introspectSchema 4 | } from 'graphql-tools'; 5 | import { HttpLink } from 'apollo-link-http'; 6 | import { fetch } from 'cross-fetch' 7 | 8 | const link = new HttpLink({ 9 | uri: 'http://localhost:8080/graphql', 10 | fetch 11 | }); 12 | 13 | export const getDgSchema = async () => { 14 | const schema = await introspectSchema(link); 15 | 16 | const executableSchema = makeRemoteExecutableSchema({ 17 | schema, 18 | link, 19 | }); 20 | 21 | return executableSchema 22 | } 23 | -------------------------------------------------------------------------------- /stackoverflow-app/apollo-dgraph/src/resolvers/index.ts: -------------------------------------------------------------------------------- 1 | import { IResolvers } from '../types/gql'; 2 | import { buildQuery } from './query' 3 | import { buildMutation } from './mutation' 4 | import { getDgSchema } from '../dgraph' 5 | 6 | export async function buildResolvers() { 7 | const dg = await getDgSchema() 8 | 9 | return { 10 | Query: buildQuery(dg), 11 | Mutation: buildMutation(dg) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /stackoverflow-app/apollo-dgraph/src/schema.ts: -------------------------------------------------------------------------------- 1 | import 'graphql-import-node'; 2 | import * as typeDefs from './schema/schema.graphql'; 3 | import { makeExecutableSchema } from 'graphql-tools'; 4 | import { buildResolvers } from './resolvers'; 5 | import { GraphQLSchema } from 'graphql'; 6 | 7 | export async function buildSchema() { 8 | return [{ 9 | typeDefs, 10 | resolvers: await buildResolvers(), 11 | }]; 12 | } 13 | -------------------------------------------------------------------------------- /stackoverflow-app/frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /stackoverflow-app/frontend/public/dgraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/stackoverflow-app/frontend/public/dgraph.png -------------------------------------------------------------------------------- /stackoverflow-app/frontend/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Dgraph GraphQL Demo 10 | 11 | 12 | 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /stackoverflow-app/frontend/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "Dgraph GraphQL Demo", 3 | "name": "Dgraph GraphQL Demo", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "theme_color": "#000000", 7 | "background_color": "#ffffff" 8 | } 9 | -------------------------------------------------------------------------------- /stackoverflow-app/frontend/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | -------------------------------------------------------------------------------- /stackoverflow-app/frontend/schema.graphql: -------------------------------------------------------------------------------- 1 | type Author { 2 | username: String! @id 3 | email: String! 4 | dob: DateTime 5 | questions: [Question] @hasInverse(field: author) 6 | answers: [Answer] @hasInverse(field: author) 7 | } 8 | 9 | interface Post { 10 | id: ID! 11 | text: String! @search(by: [fulltext]) 12 | datePublished: DateTime @search 13 | likes: Int 14 | author: Author! 15 | comments: [Comment] @hasInverse(field: commentsOn) 16 | } 17 | 18 | type Question implements Post { 19 | title: String! @search(by: [term]) 20 | tags: [String] @search(by: [exact]) 21 | answers: [Answer] @hasInverse(field: inAnswerTo) 22 | } 23 | 24 | type Answer implements Post { 25 | inAnswerTo: Question! 26 | } 27 | 28 | type Comment implements Post { 29 | commentsOn: Post! 30 | } -------------------------------------------------------------------------------- /stackoverflow-app/frontend/src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom"; 3 | import App from "./App"; 4 | 5 | it("renders without crashing", () => { 6 | const div = document.createElement("div"); 7 | ReactDOM.render(, div); 8 | ReactDOM.unmountComponentAtNode(div); 9 | }); 10 | -------------------------------------------------------------------------------- /stackoverflow-app/frontend/src/auth_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "domain": "dev-x44cgu-8.auth0.com", 3 | "clientId": "VEqUn2qGKdI69qbrRJT5dt6FBIIlnFQ3" 4 | } -------------------------------------------------------------------------------- /stackoverflow-app/frontend/src/components/PrivateRoute.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect } from "react"; 2 | import { Route } from "react-router-dom"; 3 | import { useAuth0 } from "../react-auth0-spa"; 4 | 5 | const PrivateRoute = ({ component: Component, path, ...rest }) => { 6 | const { loading, isAuthenticated, loginWithRedirect } = useAuth0(); 7 | 8 | useEffect(() => { 9 | if (loading || isAuthenticated) { 10 | return; 11 | } 12 | const fn = async () => { 13 | await loginWithRedirect({ 14 | appState: { targetUrl: path } 15 | }); 16 | }; 17 | fn(); 18 | }, [loading, isAuthenticated, loginWithRedirect, path]); 19 | 20 | const render = props => 21 | isAuthenticated === true ? : null; 22 | 23 | return ; 24 | }; 25 | 26 | export default PrivateRoute; -------------------------------------------------------------------------------- /stackoverflow-app/frontend/src/components/Question.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { useHistory } from "react-router-dom" 3 | import { Card } from 'semantic-ui-react' 4 | 5 | export default function Question({ question }) { 6 | const history = useHistory(); 7 | const viewQuestion = (questionID) => { 8 | history.push({ 9 | pathname: '/view', 10 | search: `?questionID=${questionID}` 11 | }) 12 | } 13 | return ( 14 | viewQuestion(question.id)} 16 | header={question.title} 17 | meta={question.author.username} 18 | description={question.text} 19 | /> 20 | ); 21 | } 22 | -------------------------------------------------------------------------------- /stackoverflow-app/frontend/src/index.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom"; 3 | import "bootstrap/dist/css/bootstrap.css"; 4 | import "./styles/index.css"; 5 | import 'semantic-ui-css/semantic.min.css' 6 | import App from "./components/App"; 7 | 8 | import { Auth0Provider } from "./react-auth0-spa"; 9 | import config from "./auth_config.json"; 10 | import history from "./utils/history"; 11 | 12 | 13 | const onRedirectCallback = appState => { 14 | history.push( 15 | appState && appState.targetUrl 16 | ? appState.targetUrl 17 | : window.location.pathname 18 | ); 19 | }; 20 | 21 | ReactDOM.render( 22 | 28 | 29 | , 30 | document.getElementById("root") 31 | ); 32 | -------------------------------------------------------------------------------- /stackoverflow-app/frontend/src/styles/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 4 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 12 | monospace; 13 | } 14 | 15 | .navbar-direction { 16 | flex-direction: row-reverse; 17 | } 18 | 19 | .card-pointer { 20 | cursor: pointer; 21 | } 22 | 23 | .delete-post { 24 | float: right; 25 | cursor: pointer; 26 | } 27 | 28 | .edit-post { 29 | float: right; 30 | margin-right: 5px; 31 | cursor: pointer; 32 | } 33 | 34 | .text-post { 35 | white-space: pre-wrap; 36 | margin-bottom: 10px; 37 | } 38 | 39 | .tagsset-post { 40 | float: right; 41 | } 42 | 43 | .tag-post { 44 | margin: 2px; 45 | } -------------------------------------------------------------------------------- /stackoverflow-app/frontend/src/utils/history.js: -------------------------------------------------------------------------------- 1 | import { createBrowserHistory } from "history"; 2 | export default createBrowserHistory(); -------------------------------------------------------------------------------- /stackoverflow-app/graphql-server-gateway/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /stackoverflow-app/graphql-server-gateway/index.js: -------------------------------------------------------------------------------- 1 | const { ApolloServer } = require("apollo-server"); 2 | const { ApolloGateway } = require("@apollo/gateway"); 3 | 4 | // Initialize an ApolloGateway instance and pass it an array of 5 | // your implementing service names and URLs 6 | const gateway = new ApolloGateway({ 7 | serviceList: [ 8 | { name: "project-app", url: "http://localhost:4000/graphql" }, 9 | // Define additional services here 10 | ], 11 | }); 12 | 13 | // Pass the ApolloGateway to the ApolloServer constructor 14 | const server = new ApolloServer({ 15 | gateway, 16 | 17 | // Disable subscriptions (not currently supported with ApolloGateway) 18 | subscriptions: false, 19 | }); 20 | 21 | server.listen(8082).then(({ url }) => { 22 | console.log(`🚀 Server ready at ${url}`); 23 | }); 24 | -------------------------------------------------------------------------------- /stackoverflow-app/graphql-server-gateway/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "graphql-server-cool", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "@apollo/federation": "^0.14.1", 14 | "@apollo/gateway": "^0.14.1", 15 | "apollo-server": "^2.12.0", 16 | "graphql": "^15.0.0" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /stackoverflow-app/try-apollo-schema/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /stackoverflow-app/try-apollo-schema/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "try-apollo-schema", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "dependencies": { 7 | "@apollo/federation": "^0.16.0", 8 | "apollo-link": "^1.2.14", 9 | "apollo-link-http": "^1.5.17", 10 | "apollo-server": "^2.13.1", 11 | "dgraph-js": "^20.3.0", 12 | "graphql": "^15.0.0", 13 | "graphql-tools": "^5.0.0", 14 | "grpc": "^1.24.2", 15 | "node-fetch": "^2.6.0" 16 | }, 17 | "devDependencies": { 18 | "esm": "^3.2.25", 19 | "object-assign": "^4.1.1" 20 | }, 21 | "scripts": { 22 | "start": "node -r esm index.js", 23 | "test": "echo \"Error: no test specified\" && exit 1" 24 | }, 25 | "author": "", 26 | "license": "ISC" 27 | } 28 | -------------------------------------------------------------------------------- /stackoverflow-app/v1-frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /stackoverflow-app/v1-frontend/public/dgraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/stackoverflow-app/v1-frontend/public/dgraph.png -------------------------------------------------------------------------------- /stackoverflow-app/v1-frontend/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Dgraph GraphQL Demo 10 | 11 | 12 | 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /stackoverflow-app/v1-frontend/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "Dgraph GraphQL Demo", 3 | "name": "Dgraph GraphQL Demo", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "theme_color": "#000000", 7 | "background_color": "#ffffff" 8 | } 9 | -------------------------------------------------------------------------------- /stackoverflow-app/v1-frontend/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | -------------------------------------------------------------------------------- /stackoverflow-app/v1-frontend/schema.graphql: -------------------------------------------------------------------------------- 1 | type Author { 2 | username: String! @id 3 | email: String! 4 | dob: DateTime 5 | questions: [Question] @hasInverse(field: author) 6 | answers: [Answer] @hasInverse(field: author) 7 | } 8 | 9 | interface Post { 10 | id: ID! 11 | text: String! @search(by: [fulltext]) 12 | datePublished: DateTime @search 13 | likes: Int 14 | author: Author! 15 | comments: [Comment] @hasInverse(field: commentsOn) 16 | } 17 | 18 | type Question implements Post { 19 | title: String! @search(by: [term]) 20 | tags: [String] @search(by: [exact]) 21 | answers: [Answer] @hasInverse(field: inAnswerTo) 22 | } 23 | 24 | type Answer implements Post { 25 | inAnswerTo: Question! 26 | } 27 | 28 | type Comment implements Post { 29 | commentsOn: Post! 30 | } -------------------------------------------------------------------------------- /stackoverflow-app/v1-frontend/src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom"; 3 | import App from "./App"; 4 | 5 | it("renders without crashing", () => { 6 | const div = document.createElement("div"); 7 | ReactDOM.render(, div); 8 | ReactDOM.unmountComponentAtNode(div); 9 | }); 10 | -------------------------------------------------------------------------------- /stackoverflow-app/v1-frontend/src/auth_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "domain": "dev-7xvufztt.auth0.com", 3 | "clientId": "ZVw9PlP93XZSfwVQoFLg2k1zR5n0yX18" 4 | } -------------------------------------------------------------------------------- /stackoverflow-app/v1-frontend/src/components/PrivateRoute.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect } from "react"; 2 | import { Route } from "react-router-dom"; 3 | import { useAuth0 } from "../react-auth0-spa"; 4 | 5 | const PrivateRoute = ({ component: Component, path, ...rest }) => { 6 | const { loading, isAuthenticated, loginWithRedirect } = useAuth0(); 7 | 8 | useEffect(() => { 9 | if (loading || isAuthenticated) { 10 | return; 11 | } 12 | const fn = async () => { 13 | await loginWithRedirect({ 14 | appState: { targetUrl: path } 15 | }); 16 | }; 17 | fn(); 18 | }, [loading, isAuthenticated, loginWithRedirect, path]); 19 | 20 | const render = props => 21 | isAuthenticated === true ? : null; 22 | 23 | return ; 24 | }; 25 | 26 | export default PrivateRoute; -------------------------------------------------------------------------------- /stackoverflow-app/v1-frontend/src/components/Question.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { useHistory } from "react-router-dom" 3 | import { Card } from 'semantic-ui-react' 4 | 5 | export default function Question({ question }) { 6 | const history = useHistory(); 7 | const viewQuestion = (questionID) => { 8 | history.push({ 9 | pathname: '/view', 10 | search: `?questionID=${questionID}` 11 | }) 12 | } 13 | return ( 14 | viewQuestion(question.id)} 16 | header={question.title} 17 | meta={question.author.username} 18 | description={question.text} 19 | /> 20 | ); 21 | } 22 | -------------------------------------------------------------------------------- /stackoverflow-app/v1-frontend/src/index.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom"; 3 | import "bootstrap/dist/css/bootstrap.css"; 4 | import "./styles/index.css"; 5 | import 'semantic-ui-css/semantic.min.css' 6 | import App from "./components/App"; 7 | 8 | import { Auth0Provider } from "./react-auth0-spa"; 9 | import config from "./auth_config.json"; 10 | import history from "./utils/history"; 11 | 12 | 13 | const onRedirectCallback = appState => { 14 | history.push( 15 | appState && appState.targetUrl 16 | ? appState.targetUrl 17 | : window.location.pathname 18 | ); 19 | }; 20 | 21 | ReactDOM.render( 22 | 28 | 29 | , 30 | document.getElementById("root") 31 | ); 32 | -------------------------------------------------------------------------------- /stackoverflow-app/v1-frontend/src/styles/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 4 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 12 | monospace; 13 | } 14 | 15 | .navbar-direction { 16 | flex-direction: row-reverse; 17 | } 18 | 19 | .card-pointer { 20 | cursor: pointer; 21 | } 22 | 23 | .delete-post { 24 | float: right; 25 | cursor: pointer; 26 | } 27 | 28 | .edit-post { 29 | float: right; 30 | margin-right: 5px; 31 | cursor: pointer; 32 | } 33 | 34 | .text-post { 35 | white-space: pre-wrap; 36 | margin-bottom: 10px; 37 | } 38 | 39 | .tagsset-post { 40 | float: right; 41 | } 42 | 43 | .tag-post { 44 | margin: 2px; 45 | } -------------------------------------------------------------------------------- /stackoverflow-app/v1-frontend/src/utils/history.js: -------------------------------------------------------------------------------- 1 | import { createBrowserHistory } from "history"; 2 | export default createBrowserHistory(); -------------------------------------------------------------------------------- /surveyo/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | .env 21 | 22 | npm-debug.log* 23 | yarn-debug.log* 24 | yarn-error.log* 25 | -------------------------------------------------------------------------------- /surveyo/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid" 6 | } 7 | -------------------------------------------------------------------------------- /surveyo/_redirects: -------------------------------------------------------------------------------- 1 | /* /index.html 200 2 | -------------------------------------------------------------------------------- /surveyo/apollo.config.js: -------------------------------------------------------------------------------- 1 | require('dotenv').config(); 2 | 3 | module.exports = { 4 | client: { 5 | service: { 6 | url: process.env.REACT_APP_GRAPHQL_ENDPOINT, 7 | skipSSLValidation: true, 8 | }, 9 | }, 10 | }; 11 | -------------------------------------------------------------------------------- /surveyo/auth0_snippets/add_user_rule.js: -------------------------------------------------------------------------------- 1 | function (user, context, callback) { 2 | const namespace = "https://dgraph.io/jwt/claims"; 3 | context.idToken[namespace] = 4 | { 5 | 'USER': user.email, 6 | }; 7 | 8 | return callback(null, user, context); 9 | } -------------------------------------------------------------------------------- /surveyo/netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | base = "/" 3 | publish = "build" 4 | 5 | # Default build command. 6 | command = "npm run build" 7 | [[redirects]] 8 | from = "/*" 9 | to = "/index.html" 10 | status = 200 11 | -------------------------------------------------------------------------------- /surveyo/public/Charts.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/surveyo/public/Charts.gif -------------------------------------------------------------------------------- /surveyo/public/Create-Form.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/surveyo/public/Create-Form.gif -------------------------------------------------------------------------------- /surveyo/public/charts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/surveyo/public/charts.png -------------------------------------------------------------------------------- /surveyo/public/dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/surveyo/public/dashboard.png -------------------------------------------------------------------------------- /surveyo/public/favicon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /surveyo/public/graphiql.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/surveyo/public/graphiql.png -------------------------------------------------------------------------------- /surveyo/public/loginPage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/surveyo/public/loginPage.png -------------------------------------------------------------------------------- /surveyo/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "Surveyo", 3 | "name": "Surveys, simplfied.", 4 | "icons": [ 5 | { 6 | "src": "favicon.svg" 7 | } 8 | ], 9 | "start_url": ".", 10 | "display": "standalone", 11 | "theme_color": "#000000", 12 | "background_color": "#ffffff" 13 | } 14 | -------------------------------------------------------------------------------- /surveyo/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /surveyo/src/App.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css?family=Ubuntu&display=swap'); 2 | @import url('https://fonts.googleapis.com/css2?family=Ubuntu+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap'); 3 | 4 | html, 5 | body { 6 | height: 100%; 7 | margin: 0; 8 | } 9 | 10 | body { 11 | font-family: 'Ubuntu' !important; 12 | -webkit-font-smoothing: antialiased; 13 | -moz-osx-font-smoothing: grayscale; 14 | } 15 | 16 | .box { 17 | display: flex; 18 | flex-flow: column; 19 | height: 100%; 20 | } 21 | 22 | .box .row.header { 23 | flex: 0 1 auto; 24 | } 25 | 26 | .box .row.content { 27 | flex: 1 1 auto; 28 | } 29 | 30 | .box .row.footer { 31 | flex: 0 1 40px; 32 | } 33 | 34 | main { 35 | max-width: 64rem; 36 | padding: 2rem; 37 | margin: auto; 38 | height: 100%; 39 | } 40 | 41 | code { 42 | font-family: 'Ubuntu Mono' !important; 43 | } 44 | 45 | #root { 46 | height: 100%; 47 | } 48 | -------------------------------------------------------------------------------- /surveyo/src/App.test.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | const { getByText } = render(); 7 | const linkElement = getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /surveyo/src/AuthConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "domain": "dev-m2uanjnq.us.auth0.com", 3 | "clientId": "mx6dY2HXVRxDLbUknPivqlqNhwil40qP", 4 | "audience": "https://dev-m2uanjnq.us.auth0.com/api/v2/" 5 | } 6 | -------------------------------------------------------------------------------- /surveyo/src/Charts/Chart.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {GetChartData_getForm_fields} from './__generated__/GetChartData'; 3 | import NetPromoterScore from './NetPromoterScore'; 4 | import Rating from './Rating'; 5 | import SingleChoice from './SingleChoice'; 6 | import Text from './Text'; 7 | 8 | export default function Chart(props: GetChartData_getForm_fields) { 9 | switch (props.type) { 10 | case 'NetPromoterScore': 11 | return ; 12 | case 'Rating': 13 | return ; 14 | case 'SingleChoice': 15 | return ; 16 | case 'Text': 17 | return ; 18 | default: 19 | return null; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /surveyo/src/Charts/SingleChoice.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {counter, ChartProps} from './common'; 3 | import {presetPalettes} from '@ant-design/colors'; 4 | import {Doughnut} from 'react-chartjs-2'; 5 | 6 | export default function Chart(props: ChartProps) { 7 | const count = counter( 8 | props.entries!.map((entry: any) => entry.singleChoice?.title) 9 | ); 10 | 11 | const colors = Object.values(presetPalettes) 12 | .flatMap(palette => palette.slice(5)) 13 | .sort(() => Math.random() - 0.5); 14 | 15 | const chartData = { 16 | datasets: [ 17 | { 18 | data: Object.values(count), 19 | backgroundColor: colors, 20 | }, 21 | ], 22 | labels: Object.keys(count), 23 | }; 24 | 25 | return ; 26 | } 27 | -------------------------------------------------------------------------------- /surveyo/src/Charts/Text.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactWordcloud from 'react-wordcloud'; 3 | import {presetPalettes} from '@ant-design/colors'; 4 | import {ChartProps, counter} from './common'; 5 | import {removeStopwords} from 'stopword'; 6 | 7 | export default function Chart(props: ChartProps) { 8 | const count = counter( 9 | props!.entries!.flatMap(entry => 10 | removeStopwords((entry?.text || '').split(/\s+/)) 11 | ) 12 | ); 13 | 14 | const words = Object.entries(count).map(([text, value]) => ({ 15 | text, 16 | value, 17 | })); 18 | 19 | const colors = Object.values(presetPalettes).flatMap(palette => 20 | palette.slice(5) 21 | ); 22 | 23 | return ( 24 | 35 | ); 36 | } 37 | -------------------------------------------------------------------------------- /surveyo/src/Charts/common.tsx: -------------------------------------------------------------------------------- 1 | import {GetChartData_getForm_fields} from './__generated__/GetChartData'; 2 | 3 | export type ChartProps = GetChartData_getForm_fields; 4 | 5 | export function counter(arr: any[]): Record { 6 | const count: any = {}; 7 | 8 | for (const element of arr) { 9 | if (element === null || element === undefined) { 10 | continue; 11 | } 12 | 13 | if (count[element]) { 14 | count[element]++; 15 | } else { 16 | count[element] = 1; 17 | } 18 | } 19 | 20 | return count; 21 | } 22 | -------------------------------------------------------------------------------- /surveyo/src/Charts/query.tsx: -------------------------------------------------------------------------------- 1 | import {gql} from '@apollo/client'; 2 | 3 | export const GET_CHART_DATA = gql` 4 | query GetChartData($id: ID!) { 5 | getForm(id: $id) { 6 | title 7 | fields { 8 | title 9 | type 10 | count 11 | entries { 12 | netPromoterScore 13 | rating 14 | singleChoice { 15 | title 16 | } 17 | text 18 | } 19 | } 20 | } 21 | } 22 | `; 23 | -------------------------------------------------------------------------------- /surveyo/src/Dashboard/__generated__/DeleteForm.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | // @generated 4 | // This file was automatically generated and should not be edited. 5 | 6 | // ==================================================== 7 | // GraphQL mutation operation: DeleteForm 8 | // ==================================================== 9 | 10 | export interface DeleteForm_deleteForm_form { 11 | __typename: "Form"; 12 | id: string; 13 | } 14 | 15 | export interface DeleteForm_deleteForm { 16 | __typename: "DeleteFormPayload"; 17 | form: (DeleteForm_deleteForm_form | null)[] | null; 18 | } 19 | 20 | export interface DeleteForm { 21 | deleteForm: DeleteForm_deleteForm | null; 22 | } 23 | 24 | export interface DeleteFormVariables { 25 | id: string; 26 | } 27 | -------------------------------------------------------------------------------- /surveyo/src/Dashboard/__generated__/GetSurveys.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | // @generated 4 | // This file was automatically generated and should not be edited. 5 | 6 | // ==================================================== 7 | // GraphQL query operation: GetSurveys 8 | // ==================================================== 9 | 10 | export interface GetSurveys_getUser_forms_responses { 11 | __typename: "Response"; 12 | id: string; 13 | } 14 | 15 | export interface GetSurveys_getUser_forms { 16 | __typename: "Form"; 17 | id: string; 18 | title: string; 19 | responses: GetSurveys_getUser_forms_responses[] | null; 20 | isClosed: boolean | null; 21 | } 22 | 23 | export interface GetSurveys_getUser { 24 | __typename: "User"; 25 | forms: (GetSurveys_getUser_forms | null)[] | null; 26 | } 27 | 28 | export interface GetSurveys { 29 | getUser: GetSurveys_getUser | null; 30 | } 31 | 32 | export interface GetSurveysVariables { 33 | email: string; 34 | } 35 | -------------------------------------------------------------------------------- /surveyo/src/Dashboard/__generated__/UpdateForm.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | // @generated 4 | // This file was automatically generated and should not be edited. 5 | 6 | // ==================================================== 7 | // GraphQL mutation operation: UpdateForm 8 | // ==================================================== 9 | 10 | export interface UpdateForm_updateForm_form { 11 | __typename: "Form"; 12 | isClosed: boolean | null; 13 | } 14 | 15 | export interface UpdateForm_updateForm { 16 | __typename: "UpdateFormPayload"; 17 | numUids: number | null; 18 | form: (UpdateForm_updateForm_form | null)[] | null; 19 | } 20 | 21 | export interface UpdateForm { 22 | updateForm: UpdateForm_updateForm | null; 23 | } 24 | 25 | export interface UpdateFormVariables { 26 | id: string; 27 | isClosed: boolean; 28 | } 29 | -------------------------------------------------------------------------------- /surveyo/src/Form/NetPromoterScore.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {Radio} from 'antd'; 3 | import {RadioGroupProps} from 'antd/lib/radio'; 4 | 5 | export default function Field(props: RadioGroupProps) { 6 | const buttons = []; 7 | for (let i = 0; i <= 10; i++) { 8 | buttons.push( 9 | 10 | {i} 11 | 12 | ); 13 | } 14 | 15 | return ( 16 | 17 | {buttons} 18 | 19 | ); 20 | } 21 | -------------------------------------------------------------------------------- /surveyo/src/Form/__generated__/AddResponse.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | // @generated 4 | // This file was automatically generated and should not be edited. 5 | 6 | import { AddResponseInput } from "./../../../__generated__/globalTypes"; 7 | 8 | // ==================================================== 9 | // GraphQL mutation operation: AddResponse 10 | // ==================================================== 11 | 12 | export interface AddResponse_addResponse_response { 13 | __typename: "Response"; 14 | id: string; 15 | } 16 | 17 | export interface AddResponse_addResponse { 18 | __typename: "AddResponsePayload"; 19 | response: (AddResponse_addResponse_response | null)[] | null; 20 | } 21 | 22 | export interface AddResponse { 23 | addResponse: AddResponse_addResponse | null; 24 | } 25 | 26 | export interface AddResponseVariables { 27 | response: AddResponseInput; 28 | } 29 | -------------------------------------------------------------------------------- /surveyo/src/Form/query.tsx: -------------------------------------------------------------------------------- 1 | import {gql} from '@apollo/client'; 2 | 3 | export const GET_FORM = gql` 4 | query GetForm($id: ID!) { 5 | getForm(id: $id) { 6 | id 7 | title 8 | isClosed 9 | fields(order: {asc: order}) { 10 | id 11 | title 12 | type 13 | required 14 | options(order: {asc: order}) { 15 | id 16 | title 17 | } 18 | count 19 | } 20 | } 21 | } 22 | `; 23 | 24 | export const ADD_RESPONSE = gql` 25 | mutation AddResponse($response: AddResponseInput!) { 26 | addResponse(input: [$response]) { 27 | response { 28 | id 29 | } 30 | } 31 | } 32 | `; 33 | -------------------------------------------------------------------------------- /surveyo/src/FormCreator/__generated__/AddForm.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | // @generated 4 | // This file was automatically generated and should not be edited. 5 | 6 | import { AddFormInput } from "./../../../__generated__/globalTypes"; 7 | 8 | // ==================================================== 9 | // GraphQL mutation operation: AddForm 10 | // ==================================================== 11 | 12 | export interface AddForm_addForm_form { 13 | __typename: "Form"; 14 | id: string; 15 | } 16 | 17 | export interface AddForm_addForm { 18 | __typename: "AddFormPayload"; 19 | form: (AddForm_addForm_form | null)[] | null; 20 | } 21 | 22 | export interface AddForm { 23 | addForm: AddForm_addForm | null; 24 | } 25 | 26 | export interface AddFormVariables { 27 | form: AddFormInput; 28 | } 29 | -------------------------------------------------------------------------------- /surveyo/src/FormCreator/query.tsx: -------------------------------------------------------------------------------- 1 | import {gql} from '@apollo/client'; 2 | 3 | export const ADD_FORM = gql` 4 | mutation AddForm($form: AddFormInput!) { 5 | addForm(input: [$form]) { 6 | form { 7 | id 8 | } 9 | } 10 | } 11 | `; 12 | -------------------------------------------------------------------------------- /surveyo/src/Graphiql/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | height: 100%; 4 | } 5 | 6 | #graphiql { 7 | height: 100%; 8 | min-height: 500px; 9 | display: flex; 10 | flex-direction: row; 11 | } 12 | 13 | .query-panel { 14 | width: 20%; 15 | min-width: 100px; 16 | align-self: stretch; 17 | box-sizing: border-box; 18 | background-color: gainsboro; 19 | padding: 10px 0; 20 | } 21 | 22 | .query-item { 23 | text-align: center; 24 | font-size: 16px; 25 | font-weight: 800; 26 | box-sizing: border-box; 27 | padding: 10px 15px; 28 | cursor: pointer; 29 | } 30 | 31 | .query-item:hover { 32 | background-color: grey; 33 | } 34 | 35 | .query-item.active { 36 | background-color: orange; 37 | color: white; 38 | } 39 | 40 | .graphiql-panel { 41 | width: 80%; 42 | align-self: stretch; 43 | box-sizing: border-box; 44 | } 45 | 46 | .graphiql-container .toolbar { 47 | display: none !important; 48 | } 49 | -------------------------------------------------------------------------------- /surveyo/src/common/FormClosed.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import {Button, Result} from 'antd'; 4 | import {Link} from 'react-router-dom'; 5 | 6 | export default function SurveyClose() { 7 | return ( 8 | 12 | 13 | 14 | } 15 | /> 16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /surveyo/src/common/Result404.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import {Button, Result} from 'antd'; 4 | import {Link} from 'react-router-dom'; 5 | 6 | export default function Result404() { 7 | return ( 8 | 14 | 15 | 16 | } 17 | /> 18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /surveyo/src/common/Result500.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import {Button, Result} from 'antd'; 4 | import {Link} from 'react-router-dom'; 5 | 6 | export default function Result404() { 7 | return ( 8 | 14 | 15 | 16 | } 17 | /> 18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /surveyo/src/common/index.tsx: -------------------------------------------------------------------------------- 1 | import Result404 from './Result404'; 2 | import Result500 from './Result500'; 3 | import FormClosed from './FormClosed'; 4 | 5 | export {Result404, Result500, FormClosed}; 6 | -------------------------------------------------------------------------------- /surveyo/src/history.js: -------------------------------------------------------------------------------- 1 | import {createBrowserHistory} from 'history'; 2 | export default createBrowserHistory(); 3 | -------------------------------------------------------------------------------- /surveyo/src/images/slash-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/surveyo/src/images/slash-logo.png -------------------------------------------------------------------------------- /surveyo/src/index.tsx: -------------------------------------------------------------------------------- 1 | import './App.css'; 2 | import 'antd/dist/antd.css'; 3 | 4 | import React from 'react'; 5 | import ReactDOM from 'react-dom'; 6 | import App from './App'; 7 | import * as serviceWorker from './serviceWorker'; 8 | import {Auth0Provider} from '@auth0/auth0-react'; 9 | import config from './AuthConfig.json'; 10 | import onRedirectCallback from './ApolloConfig'; 11 | 12 | ReactDOM.render( 13 | 14 | 21 | 22 | 23 | , 24 | document.getElementById('root') 25 | ); 26 | 27 | // If you want your app to work offline and load faster, you can change 28 | // unregister() to register() below. Note this comes with some pitfalls. 29 | // Learn more about service workers: https://bit.ly/CRA-PWA 30 | serviceWorker.unregister(); 31 | -------------------------------------------------------------------------------- /surveyo/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /surveyo/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /surveyo/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "module": "esnext", 16 | "moduleResolution": "node", 17 | "resolveJsonModule": true, 18 | "isolatedModules": true, 19 | "noEmit": true, 20 | "jsx": "react" 21 | }, 22 | "include": [ 23 | "src" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /todo-app-noauth/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | 25 | -------------------------------------------------------------------------------- /todo-app-noauth/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app-noauth/public/favicon.ico -------------------------------------------------------------------------------- /todo-app-noauth/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | React + GraphQL + Dgraph - ToDo App 14 | 15 | 16 | 17 |
18 |
19 |

Double-click to edit a todo

20 |

Created by Dgraph Labs

21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /todo-app-noauth/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React Todo App", 3 | "name": "React Todo GraphQL App powered by Dgraph", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /todo-app-noauth/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /todo-app-noauth/schema.graphql: -------------------------------------------------------------------------------- 1 | type Task { 2 | id: ID! 3 | title: String! @search(by: [fulltext]) 4 | completed: Boolean! @search 5 | } 6 | -------------------------------------------------------------------------------- /todo-app-noauth/src/App.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app-noauth/src/App.css -------------------------------------------------------------------------------- /todo-app-noauth/src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | import ApolloClient from "apollo-client"; 4 | import { InMemoryCache } from "apollo-cache-inmemory"; 5 | import { ApolloProvider } from "@apollo/react-hooks"; 6 | import { createHttpLink } from "apollo-link-http"; 7 | 8 | import TodoApp from "./TodoApp"; 9 | import './App.css'; 10 | 11 | const createApolloClient = () => { 12 | const httpLink = createHttpLink({ 13 | uri: process.env.REACT_APP_GRAPHQL_ENDPOINT, 14 | options: { 15 | reconnect: true, 16 | }, 17 | }); 18 | 19 | return new ApolloClient({ 20 | link: httpLink, 21 | cache: new InMemoryCache() 22 | }); 23 | } 24 | 25 | const App = () => { 26 | const client = createApolloClient(); 27 | return ( 28 | 29 |
30 |

todos

31 | 32 |
33 |
34 | ); 35 | } 36 | 37 | export default App 38 | -------------------------------------------------------------------------------- /todo-app-noauth/src/Utils.js: -------------------------------------------------------------------------------- 1 | export default { 2 | pluralize: (count, word) => { 3 | return count === 1 ? word : word + 's'; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /todo-app-noauth/src/defs.js: -------------------------------------------------------------------------------- 1 | export default { 2 | ALL_TODOS: 'all', 3 | ACTIVE_TODOS: 'active', 4 | COMPLETED_TODOS: 'completed', 5 | } 6 | -------------------------------------------------------------------------------- /todo-app-noauth/src/history.js: -------------------------------------------------------------------------------- 1 | import { createBrowserHistory } from "history"; 2 | 3 | export default createBrowserHistory(); 4 | -------------------------------------------------------------------------------- /todo-app-noauth/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import 'todomvc-app-css/index.css' 4 | 5 | import App from './App'; 6 | 7 | ReactDOM.render( 8 | , 9 | document.getElementById("root") 10 | ); 11 | -------------------------------------------------------------------------------- /todo-app-noauth/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /todo-app-noauth/todo-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app-noauth/todo-1.png -------------------------------------------------------------------------------- /todo-app-noauth/todo-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app-noauth/todo-2.png -------------------------------------------------------------------------------- /todo-app-noauth/todo-graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app-noauth/todo-graph.png -------------------------------------------------------------------------------- /todo-app-react/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_STORE 2 | node_modules 3 | scripts/flow/*/.flowconfig 4 | .flowconfig 5 | *~ 6 | *.pyc 7 | .grunt 8 | _SpecRunner.html 9 | __benchmarks__ 10 | build/ 11 | remote-repo/ 12 | coverage/ 13 | .module-cache 14 | fixtures/dom/public/react-dom.js 15 | fixtures/dom/public/react.js 16 | test/the-files-to-test.generated.js 17 | *.log* 18 | chrome-user-data 19 | *.sublime-project 20 | *.sublime-workspace 21 | .idea 22 | *.iml 23 | .vscode 24 | *.swp 25 | *.swo 26 | 27 | packages/react-devtools-core/dist 28 | packages/react-devtools-extensions/chrome/build 29 | packages/react-devtools-extensions/chrome/*.crx 30 | packages/react-devtools-extensions/chrome/*.pem 31 | packages/react-devtools-extensions/firefox/build 32 | packages/react-devtools-extensions/firefox/*.xpi 33 | packages/react-devtools-extensions/firefox/*.pem 34 | packages/react-devtools-extensions/shared/build 35 | packages/react-devtools-inline/dist 36 | packages/react-devtools-shell/dist 37 | -------------------------------------------------------------------------------- /todo-app-react/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app-react/public/favicon.ico -------------------------------------------------------------------------------- /todo-app-react/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | React + GraphQL + Dgraph - ToDo App 12 | 13 | 14 | 15 | 16 |
17 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /todo-app-react/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React Todo App", 3 | "name": "React Todo GraphQL App powered by Dgraph", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /todo-app-react/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /todo-app-react/schema.graphql: -------------------------------------------------------------------------------- 1 | type Task @auth( 2 | query: { rule: """ 3 | query($USER: String!) { 4 | queryTask { 5 | user(filter: { username: { eq: $USER } }) { 6 | __typename 7 | } 8 | } 9 | }"""}), { 10 | id: ID! 11 | title: String! @search(by: [fulltext]) 12 | completed: Boolean! @search 13 | user: User! 14 | } 15 | 16 | type User { 17 | username: String! @id @search(by: [hash]) 18 | name: String @search(by: [exact]) 19 | tasks: [Task] @hasInverse(field: user) 20 | } 21 | 22 | 23 | # Dgraph.Authorization X-Auth-Token https://dgraph.io/jwt/claims RS256 "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp/qw/KXH23bpOuhXzsDp\ndo9bGNqjd/OkH2LkCT0PKFx5i/lmvFXdd04fhJD0Z0K3pUe7xHcRn1pIbZWlhwOR\n7siaCh9L729OQjnrxU/aPOKwsD19YmLWwTeVpE7vhDejhnRaJ7Pz8GImX/z/Xo50\nPFSYdX28Fb3kssfo+cMBz2+7h1prKeLZyDk30ItK9MMj9S5y+UKHDwfLV/ZHSd8m\nVVEYRXUNNzLsxD2XaEC5ym2gCjEP1QTgago0iw3Bm2rNAMBePgo4OMgYjH9wOOuS\nVnyvHhZdwiZAd1XtJSehORzpErgDuV2ym3mw1G9mrDXDzX9vr5l5CuBc3BjnvcFC\nFwIDAQAB\n-----END PUBLIC KEY-----" 24 | -------------------------------------------------------------------------------- /todo-app-react/src/App.css: -------------------------------------------------------------------------------- 1 | .navheader { 2 | margin: auto 0px; 3 | padding: 15px; 4 | background: #f5f5f5; 5 | } 6 | 7 | .token { 8 | line-height: 24px; 9 | height: 24px; 10 | } 11 | 12 | .token input { 13 | width: 80%; 14 | margin-right: 5px; 15 | } 16 | 17 | .token img { 18 | cursor: pointer; 19 | height: 16px; 20 | } 21 | -------------------------------------------------------------------------------- /todo-app-react/src/AuthToken.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import './App.css'; 3 | import Clipboard from 'react-clipboard.js'; 4 | 5 | // FIXME: We should refactor this UI to have the copy button within the input box 6 | const AuthToken = ({ token }) => { 7 | return
8 | X-Auth-Token: {" "} 9 | 10 | 11 | 12 | 13 | Copy To Clipboard 14 | 15 |
; 16 | } 17 | 18 | export default AuthToken; 19 | -------------------------------------------------------------------------------- /todo-app-react/src/NavBar.css: -------------------------------------------------------------------------------- 1 | .navbar ul { 2 | list-style-type: none; 3 | margin: 0; 4 | padding: 0; 5 | height: 47px; 6 | } 7 | .navbar li { 8 | display: inline; 9 | float: left; 10 | } 11 | .navbar li:first-child { 12 | margin-right: 10px; 13 | } 14 | .navbar li a { 15 | display: block; 16 | color: white; 17 | background-color: #b83f45; 18 | text-align: center; 19 | padding: 14px 16px; 20 | font-size: large; 21 | font-weight: bold; 22 | text-decoration: none; 23 | } 24 | /* Change the link color to #111 (black) on hover */ 25 | .navbar li a:hover { 26 | background-color: silver; 27 | color: white; 28 | } 29 | -------------------------------------------------------------------------------- /todo-app-react/src/PrivateRoute.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect } from "react"; 2 | import { Route } from "react-router-dom"; 3 | import { useAuth0 } from "./react-auth0-spa"; 4 | 5 | const PrivateRoute = ({ component: Component, path, ...rest }) => { 6 | const { loading, isAuthenticated, loginWithRedirect } = useAuth0(); 7 | 8 | useEffect(() => { 9 | if (loading || isAuthenticated) { 10 | return; 11 | } 12 | const fn = async () => { 13 | await loginWithRedirect({ 14 | appState: {targetUrl: window.location.pathname} 15 | }); 16 | }; 17 | fn(); 18 | }, [loading, isAuthenticated, loginWithRedirect, path]); 19 | 20 | const render = props => 21 | isAuthenticated === true ? : null; 22 | 23 | return ; 24 | }; 25 | 26 | export default PrivateRoute; -------------------------------------------------------------------------------- /todo-app-react/src/Profile.css: -------------------------------------------------------------------------------- 1 | .profile { 2 | padding: 15px; 3 | } 4 | .profile-img { 5 | display: block; 6 | margin: 0 auto; 7 | border-radius: 50%; 8 | } 9 | -------------------------------------------------------------------------------- /todo-app-react/src/Profile.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { useAuth0 } from "./react-auth0-spa"; 3 | import './Profile.css'; 4 | 5 | const Profile = () => { 6 | const { loading, user } = useAuth0(); 7 | 8 | if (loading || !user) { 9 | return
Loading...
; 10 | } 11 | 12 | return ( 13 |
14 | Profile 15 |

Name: {user.nickname}

16 |

Email: {user.email}

17 |
18 | ); 19 | }; 20 | 21 | export default Profile; 22 | -------------------------------------------------------------------------------- /todo-app-react/src/QueryHistory.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { observer } from "mobx-react-lite"; 3 | import QueryStore from './QueryStore'; 4 | import './App.css'; 5 | 6 | const QueryHistory = () => { 7 | return
{QueryStore.query}
8 | } 9 | 10 | export default observer(QueryHistory); -------------------------------------------------------------------------------- /todo-app-react/src/QueryStore.jsx: -------------------------------------------------------------------------------- 1 | import { decorate, observable, action } from "mobx"; 2 | 3 | class QueryStore { 4 | query = "" 5 | 6 | setQuery(query) { 7 | this.query = query; 8 | } 9 | } 10 | 11 | decorate(QueryStore, { 12 | query: observable, 13 | setQuery: action, 14 | }); 15 | 16 | export default new QueryStore(); -------------------------------------------------------------------------------- /todo-app-react/src/Utils.js: -------------------------------------------------------------------------------- 1 | export default { 2 | pluralize: (count, word) => { 3 | return count === 1 ? word : word + 's'; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /todo-app-react/src/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "domain": "dev-nus7dz9x.auth0.com", 3 | "clientId": "Q1nC2kLsN6KQTX1UPdiBS6AhXRx9KwKl" 4 | } 5 | -------------------------------------------------------------------------------- /todo-app-react/src/defs.js: -------------------------------------------------------------------------------- 1 | export default { 2 | ALL_TODOS: 'all', 3 | ACTIVE_TODOS: 'active', 4 | COMPLETED_TODOS: 'completed', 5 | } 6 | -------------------------------------------------------------------------------- /todo-app-react/src/history.js: -------------------------------------------------------------------------------- 1 | import { createBrowserHistory } from "history"; 2 | 3 | export default createBrowserHistory(); 4 | -------------------------------------------------------------------------------- /todo-app-react/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import 'todomvc-app-css/index.css' 4 | 5 | import { Auth0Provider } from "./react-auth0-spa"; 6 | import config from "./config.json"; 7 | import history from "./history"; 8 | 9 | /* A function that routes the user to the right place after login */ 10 | const onRedirectCallback = appState => { 11 | history.push( 12 | appState && appState.targetUrl 13 | ? appState.targetUrl 14 | : window.location.pathname 15 | ); 16 | }; 17 | 18 | ReactDOM.render( 19 | , 25 | document.getElementById("root") 26 | ); 27 | -------------------------------------------------------------------------------- /todo-app-react/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /todo-app-react/src/slash_endpoint.js: -------------------------------------------------------------------------------- 1 | const STORAGE_KEY = "slash-endpoint" 2 | 3 | function askForEndpoint() { 4 | const endpoint = prompt("Please enter your Slash GraphQL Endpoint") 5 | console.log(endpoint) 6 | if (endpoint && global.localStorage && endpoint.endsWith("/graphql")) { 7 | global.localStorage.setItem(STORAGE_KEY, endpoint) 8 | } 9 | return endpoint; 10 | } 11 | 12 | export function getSlashGraphQLEndpoint() { 13 | const localStorageEndpoint = global.localStorage && global.localStorage.getItem(STORAGE_KEY); 14 | 15 | if (localStorageEndpoint) { 16 | return localStorageEndpoint 17 | } 18 | 19 | const defaultEndpoint = process.env.REACT_APP_GRAPHQL_ENDPOINT; 20 | if(defaultEndpoint) { 21 | return defaultEndpoint; 22 | } 23 | 24 | return askForEndpoint(); 25 | } 26 | 27 | export function changeSlashGraphQLEndpoint() { 28 | global.localStorage && global.localStorage.removeItem(STORAGE_KEY) 29 | askForEndpoint(); 30 | window.location.reload() 31 | } 32 | global.changeSlashGraphQLEndpoint = changeSlashGraphQLEndpoint; 33 | -------------------------------------------------------------------------------- /todo-app-react/todo-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app-react/todo-1.png -------------------------------------------------------------------------------- /todo-app-react/todo-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app-react/todo-2.png -------------------------------------------------------------------------------- /todo-app-react/todo-graph-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app-react/todo-graph-2.png -------------------------------------------------------------------------------- /todo-app-react/todo-graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app-react/todo-graph.png -------------------------------------------------------------------------------- /todo-app/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw? 22 | -------------------------------------------------------------------------------- /todo-app/README.md: -------------------------------------------------------------------------------- 1 | # todo-app 2 | 3 | ## Project setup 4 | ``` 5 | yarn install 6 | ``` 7 | 8 | ### Compiles and hot-reloads for development 9 | ``` 10 | yarn run serve 11 | ``` 12 | 13 | ### Compiles and minifies for production 14 | ``` 15 | yarn run build 16 | ``` 17 | 18 | ### Run your tests 19 | ``` 20 | yarn run test 21 | ``` 22 | 23 | ### Lints and fixes files 24 | ``` 25 | yarn run lint 26 | ``` 27 | 28 | ### Customize configuration 29 | See [Configuration Reference](https://cli.vuejs.org/config/). 30 | -------------------------------------------------------------------------------- /todo-app/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /todo-app/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/public/favicon.ico -------------------------------------------------------------------------------- /todo-app/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= htmlWebpackPlugin.options.title %> 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /todo-app/schema.graphql: -------------------------------------------------------------------------------- 1 | type Todo { 2 | id: ID! 3 | title: String! 4 | completed: Boolean! 5 | } -------------------------------------------------------------------------------- /todo-app/src/App.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 18 | 19 | 29 | -------------------------------------------------------------------------------- /todo-app/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/src/assets/logo.png -------------------------------------------------------------------------------- /todo-app/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import App from "./App.vue"; 3 | import VueApollo from "vue-apollo"; 4 | 5 | import ApolloClient from "apollo-boost"; 6 | import { InMemoryCache } from "apollo-boost"; 7 | 8 | Vue.use(VueApollo); 9 | 10 | Vue.config.productionTip = false; 11 | 12 | const client = new ApolloClient({ 13 | uri: "http://localhost:8080/graphql", 14 | cache: new InMemoryCache(), 15 | }); 16 | 17 | const apolloProvider = new VueApollo({ 18 | defaultClient: client, 19 | }); 20 | 21 | new Vue({ 22 | apolloProvider, 23 | render: (h) => h(App), 24 | }).$mount("#app"); 25 | -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: f139b11009aeb8ed2a3a3aa8b0066e482709dde3 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/android/app/src/main/kotlin/io/dgraph/fluttertodoapp/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package io.dgraph.fluttertodoapp 2 | 3 | import androidx.annotation.NonNull; 4 | import io.flutter.embedding.android.FlutterActivity 5 | import io.flutter.embedding.engine.FlutterEngine 6 | import io.flutter.plugins.GeneratedPluginRegistrant 7 | 8 | class MainActivity: FlutterActivity() { 9 | override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { 10 | GeneratedPluginRegistrant.registerWith(flutterEngine); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.3.50' 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.4.2' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | jcenter() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.enableR8=true 3 | android.useAndroidX=true 4 | android.enableJetifier=true 5 | -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip 7 | -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() 4 | 5 | def plugins = new Properties() 6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') 7 | if (pluginsFile.exists()) { 8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } 9 | } 10 | 11 | plugins.each { name, path -> 12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() 13 | include ":$name" 14 | project(":$name").projectDir = pluginDirectory 15 | } 16 | -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.mode2v3 3 | *.moved-aside 4 | *.pbxuser 5 | *.perspectivev3 6 | **/*sync/ 7 | .sconsign.dblite 8 | .tags* 9 | **/.vagrant/ 10 | **/DerivedData/ 11 | Icon? 12 | **/Pods/ 13 | **/.symlinks/ 14 | profile 15 | xcuserdata 16 | **/.generated/ 17 | Flutter/App.framework 18 | Flutter/Flutter.framework 19 | Flutter/Flutter.podspec 20 | Flutter/Generated.xcconfig 21 | Flutter/app.flx 22 | Flutter/app.zip 23 | Flutter/flutter_assets/ 24 | Flutter/flutter_export_environment.sh 25 | ServiceDefinitions.json 26 | Runner/GeneratedPluginRegistrant.* 27 | 28 | # Exceptions to above rules. 29 | !default.mode1v3 30 | !default.mode2v3 31 | !default.pbxuser 32 | !default.perspectivev3 33 | -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/schema.graphql: -------------------------------------------------------------------------------- 1 | type Task { 2 | id: ID! 3 | title: String! @search(by: [fulltext]) 4 | completed: Boolean! @search 5 | } -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/todo-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/todo-1.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/todo-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/todo-2.png -------------------------------------------------------------------------------- /todo-app/todo-app-flutter/todo-graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-flutter/todo-graph.png -------------------------------------------------------------------------------- /todo-app/todo-app-react/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-react/public/favicon.ico -------------------------------------------------------------------------------- /todo-app/todo-app-react/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | React + GraphQL + Dgraph - ToDo App 15 | 16 | 17 | 18 |
19 |
20 |

Double-click to edit a todo

21 |

Created by Dgraph Labs

22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /todo-app/todo-app-react/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /todo-app/todo-app-react/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /todo-app/todo-app-react/schema.graphql: -------------------------------------------------------------------------------- 1 | type Task { 2 | id: ID! 3 | title: String! @search(by: [fulltext]) 4 | completed: Boolean! @search 5 | } -------------------------------------------------------------------------------- /todo-app/todo-app-react/src/Utils.js: -------------------------------------------------------------------------------- 1 | export default { 2 | pluralize: (count, word) => { 3 | return count === 1 ? word : word + 's'; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /todo-app/todo-app-react/src/defs.js: -------------------------------------------------------------------------------- 1 | export default { 2 | ALL_TODOS: 'all', 3 | ACTIVE_TODOS: 'active', 4 | COMPLETED_TODOS: 'completed', 5 | } 6 | -------------------------------------------------------------------------------- /todo-app/todo-app-react/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import 'todomvc-app-css/index.css' 4 | 5 | import TodoApp from './TodoApp' 6 | 7 | import ApolloClient from "apollo-client"; 8 | import { InMemoryCache } from "apollo-cache-inmemory"; 9 | import { ApolloProvider } from "@apollo/react-hooks"; 10 | import { createHttpLink } from "apollo-link-http"; 11 | 12 | const httpLink = createHttpLink({ 13 | uri: "http://localhost:8080/graphql" 14 | }); 15 | 16 | const client = new ApolloClient({ 17 | link: httpLink, 18 | cache: new InMemoryCache(), 19 | request: operation => { 20 | operation.setContext({ 21 | fetchOptions: { 22 | mode: "no-cors" 23 | } 24 | }); 25 | }, 26 | defaultOptions: { 27 | query: { 28 | fetchPolicy: 'network-only', 29 | errorPolicy: 'all' 30 | } 31 | } 32 | }); 33 | 34 | 35 | ReactDOM.render( 36 | 37 | 38 | , 39 | document.getElementById('root') 40 | ); 41 | -------------------------------------------------------------------------------- /todo-app/todo-app-react/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /todo-app/todo-app-react/todo-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-react/todo-1.png -------------------------------------------------------------------------------- /todo-app/todo-app-react/todo-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-react/todo-2.png -------------------------------------------------------------------------------- /todo-app/todo-app-react/todo-graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-react/todo-graph.png -------------------------------------------------------------------------------- /todo-app/todo-app-vue/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw? 22 | -------------------------------------------------------------------------------- /todo-app/todo-app-vue/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /todo-app/todo-app-vue/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-vue/public/favicon.ico -------------------------------------------------------------------------------- /todo-app/todo-app-vue/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= htmlWebpackPlugin.options.title %> 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /todo-app/todo-app-vue/schema.graphql: -------------------------------------------------------------------------------- 1 | type Task { 2 | id: ID! 3 | title: String! @search(by: [fulltext]) 4 | completed: Boolean! @search 5 | } -------------------------------------------------------------------------------- /todo-app/todo-app-vue/src/TodoFooter.vue: -------------------------------------------------------------------------------- 1 | 16 | -------------------------------------------------------------------------------- /todo-app/todo-app-vue/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-vue/src/assets/logo.png -------------------------------------------------------------------------------- /todo-app/todo-app-vue/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import App from "./TodoApp.vue"; 3 | import VueApollo from "vue-apollo"; 4 | import "todomvc-app-css/index.css"; 5 | 6 | import ApolloClient from "apollo-boost"; 7 | import { InMemoryCache } from "apollo-boost"; 8 | 9 | Vue.use(VueApollo); 10 | 11 | Vue.config.productionTip = false; 12 | 13 | const client = new ApolloClient({ 14 | uri: "http://localhost:8080/graphql", 15 | cache: new InMemoryCache(), 16 | }); 17 | 18 | const apolloProvider = new VueApollo({ 19 | defaultClient: client, 20 | }); 21 | 22 | var app = new Vue({ 23 | apolloProvider, 24 | render: (h) => h(App), 25 | }) 26 | 27 | app.$mount("#app"); 28 | -------------------------------------------------------------------------------- /todo-app/todo-app-vue/todo-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-vue/todo-1.png -------------------------------------------------------------------------------- /todo-app/todo-app-vue/todo-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-vue/todo-2.png -------------------------------------------------------------------------------- /todo-app/todo-app-vue/todo-graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-app-vue/todo-graph.png -------------------------------------------------------------------------------- /todo-app/todo-nextjs-ssr/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | 21 | # debug 22 | npm-debug.log* 23 | yarn-debug.log* 24 | yarn-error.log* 25 | 26 | # local env files 27 | .env.local 28 | .env.development.local 29 | .env.test.local 30 | .env.production.local 31 | -------------------------------------------------------------------------------- /todo-app/todo-nextjs-ssr/README.md: -------------------------------------------------------------------------------- 1 | This app was made for the [blog](https://dgraph.io/blog/post/how-does-graphql-subscription/), in which we learn "How GraphQL Subscriptions Work". 2 | 3 | ## Getting Started 4 | 5 | Install the dependencies: 6 | 7 | ```bash 8 | npm i 9 | # or 10 | yarn install 11 | ``` 12 | 13 | Run the development server: 14 | 15 | ```bash 16 | npm run dev 17 | # or 18 | yarn dev 19 | ``` 20 | 21 | Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. 22 | -------------------------------------------------------------------------------- /todo-app/todo-nextjs-ssr/next.config.js: -------------------------------------------------------------------------------- 1 | const withCSS = require("@zeit/next-css"); 2 | module.exports = withCSS({ 3 | webpack: function (config) { 4 | config.module.rules.push({ 5 | test: /\.(eot|woff|woff2|ttf|svg|png|jpg|gif)$/, 6 | use: { 7 | loader: "url-loader", 8 | options: { 9 | limit: 100000, 10 | name: "[name].[ext]", 11 | }, 12 | }, 13 | }); 14 | return config; 15 | }, 16 | }); 17 | -------------------------------------------------------------------------------- /todo-app/todo-nextjs-ssr/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-app", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start" 9 | }, 10 | "dependencies": { 11 | "@apollo/client": "^3.0.0-rc.5", 12 | "@apollo/link-ws": "^2.0.0-beta.3", 13 | "@zeit/next-css": "^1.0.1", 14 | "graphql": "^15.1.0", 15 | "next": "9.4.4", 16 | "react": "16.13.1", 17 | "react-dom": "16.13.1", 18 | "semantic-ui-css": "^2.4.1", 19 | "semantic-ui-react": "^0.88.2", 20 | "subscriptions-transport-ws": "^0.9.16" 21 | }, 22 | "devDependencies": { 23 | "css-loader": "^3.6.0", 24 | "file-loader": "^6.0.0", 25 | "url-loader": "^4.1.0" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /todo-app/todo-nextjs-ssr/public/diggy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-nextjs-ssr/public/diggy.png -------------------------------------------------------------------------------- /todo-app/todo-nextjs-ssr/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-app/todo-nextjs-ssr/public/favicon.ico -------------------------------------------------------------------------------- /todo-app/todo-nextjs-ssr/schema.graphql: -------------------------------------------------------------------------------- 1 | type Todo @withSubscription { 2 | id: ID! 3 | title: String! 4 | description: String! 5 | completed: Boolean! 6 | } 7 | -------------------------------------------------------------------------------- /todo-react-firebase/.env: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-react-firebase/.env -------------------------------------------------------------------------------- /todo-react-firebase/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | 25 | # config 26 | src/config.json 27 | -------------------------------------------------------------------------------- /todo-react-firebase/functions/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /todo-react-firebase/functions/index.js: -------------------------------------------------------------------------------- 1 | const functions = require('firebase-functions'); 2 | const admin = require('firebase-admin'); 3 | admin.initializeApp(); 4 | 5 | exports.addUserClaim = functions.https.onCall((data, context) => { 6 | return admin.auth().getUserByEmail(data.email).then(user=>{ 7 | return admin.auth().setCustomUserClaims(user.uid, { 8 | "https://dgraph.io/jwt/claims":{ 9 | "USER": data.email, 10 | "isAuthenticated" : "true" 11 | } 12 | }); 13 | }).then(() => { 14 | return { 15 | message: `Success!` 16 | } 17 | }).catch(err => { 18 | return err 19 | }) 20 | }) 21 | -------------------------------------------------------------------------------- /todo-react-firebase/functions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "functions", 3 | "description": "Cloud Functions for Firebase", 4 | "scripts": { 5 | "lint": "eslint .", 6 | "serve": "firebase emulators:start --only functions", 7 | "shell": "firebase functions:shell", 8 | "start": "npm run shell", 9 | "deploy": "firebase deploy --only functions", 10 | "logs": "firebase functions:log" 11 | }, 12 | "engines": { 13 | "node": "8" 14 | }, 15 | "main": "index.js", 16 | "dependencies": { 17 | "firebase-admin": "^8.10.0", 18 | "firebase-functions": "^3.6.1" 19 | }, 20 | "devDependencies": { 21 | "eslint": "^5.12.0", 22 | "eslint-plugin-promise": "^4.0.1", 23 | "firebase-functions-test": "^0.2.0" 24 | }, 25 | "private": true 26 | } 27 | -------------------------------------------------------------------------------- /todo-react-firebase/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-react-firebase/public/favicon.ico -------------------------------------------------------------------------------- /todo-react-firebase/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | React + GraphQL + Dgraph - ToDo App 14 | 15 | 16 | 17 |
18 |
19 |

Double-click to edit a todo

20 |

Created by Dgraph Labs

21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /todo-react-firebase/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React Todo App", 3 | "name": "React Todo GraphQL App powered by Dgraph", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /todo-react-firebase/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /todo-react-firebase/schema.graphql: -------------------------------------------------------------------------------- 1 | type Task @auth( 2 | query: { rule: """ 3 | query($USER: String!) { 4 | queryTask { 5 | user(filter: { username: { eq: $USER } }) { 6 | __typename 7 | } 8 | } 9 | }"""} 10 | add: { rule: """ 11 | query($USER: String!) { 12 | queryTask { 13 | user(filter: { username: { eq: $USER } }) { 14 | __typename 15 | } 16 | } 17 | }"""}){ 18 | id: ID! 19 | title: String! @search(by: [fulltext]) 20 | completed: Boolean! @search 21 | user: User! 22 | } 23 | type User { 24 | username: String! @id @search(by: [hash]) 25 | name: String 26 | tasks: [Task] @hasInverse(field: user) 27 | } 28 | 29 | # Dgraph.Authorization {"JWKUrl":"https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com", "Namespace": "https://dgraph.io/jwt/claims", "Audience": ["your-project-id"], "Header": "X-Auth-Token"} 30 | -------------------------------------------------------------------------------- /todo-react-firebase/src/NavBar.css: -------------------------------------------------------------------------------- 1 | .navbar ul { 2 | list-style-type: none; 3 | margin: 0; 4 | padding: 0; 5 | height: 47px; 6 | } 7 | .navbar li { 8 | display: inline; 9 | float: left; 10 | } 11 | .navbar li:first-child { 12 | margin-right: 10px; 13 | } 14 | .navbar li a { 15 | display: block; 16 | color: white; 17 | background-color: #b83f45; 18 | text-align: center; 19 | padding: 14px 16px; 20 | font-size: large; 21 | font-weight: bold; 22 | text-decoration: none; 23 | } 24 | /* Change the link color to #111 (black) on hover */ 25 | .navbar li a:hover { 26 | background-color: silver; 27 | color: white; 28 | } -------------------------------------------------------------------------------- /todo-react-firebase/src/NavBar.js: -------------------------------------------------------------------------------- 1 | import React, { useContext } from "react"; 2 | import { Link } from "react-router-dom"; 3 | import { AuthContext } from './Auth'; 4 | import app from "./base.js"; 5 | 6 | import './NavBar.css'; 7 | 8 | const NavBar = () => { 9 | const { loading, currentUser } = useContext(AuthContext); 10 | 11 | if (loading) { 12 | return
Loading...
13 | } 14 | 15 | return ( 16 |
17 |
    18 | {currentUser && ( 19 | 20 |
  • 21 | Home 22 |
  • 23 |
  • 24 | Profile 25 |
  • 26 |
  • 27 | app.auth().signOut()}> 28 | Log out 29 | 30 |
  • 31 |
    32 | )} 33 |
34 |
35 | ); 36 | }; 37 | 38 | export default NavBar; -------------------------------------------------------------------------------- /todo-react-firebase/src/PrivateRoute.js: -------------------------------------------------------------------------------- 1 | import React, { useContext } from "react"; 2 | import { Route, Redirect } from "react-router-dom"; 3 | import { AuthContext } from "./Auth"; 4 | 5 | const PrivateRoute = ({ component: RouteComponent, ...rest }) => { 6 | const {currentUser} = useContext(AuthContext); 7 | return ( 8 | 11 | !!currentUser ? ( 12 | 13 | ) : ( 14 | 15 | ) 16 | } 17 | /> 18 | ); 19 | }; 20 | 21 | 22 | export default PrivateRoute 23 | -------------------------------------------------------------------------------- /todo-react-firebase/src/Profile.css: -------------------------------------------------------------------------------- 1 | .profile { 2 | padding: 15px; 3 | } 4 | .profile-img { 5 | display: block; 6 | margin: 0 auto; 7 | border-radius: 50%; 8 | } -------------------------------------------------------------------------------- /todo-react-firebase/src/Profile.js: -------------------------------------------------------------------------------- 1 | import React, { useContext } from "react"; 2 | import {AuthContext} from "./Auth.js"; 3 | import './Profile.css'; 4 | 5 | const Profile = () => { 6 | const { currentUser } = useContext(AuthContext); 7 | 8 | if (!currentUser) { 9 | return
{currentUser.email}
; 10 | } 11 | 12 | return ( 13 |
14 | Profile 15 |

Name: {currentUser.nickname}

16 |

Email: {currentUser.email}

17 |
18 | ); 19 | }; 20 | 21 | export default Profile; -------------------------------------------------------------------------------- /todo-react-firebase/src/SignUp.js: -------------------------------------------------------------------------------- 1 | import React, { useCallback } from "react"; 2 | import { withRouter } from "react-router"; 3 | import app from "./base"; 4 | 5 | const SignUp = ({ history }) => { 6 | const handleSignUp = useCallback(async event => { 7 | event.preventDefault(); 8 | const { email, password } = event.target.elements; 9 | try { 10 | await app 11 | .auth() 12 | .createUserWithEmailAndPassword(email.value, password.value); 13 | history.push("/"); 14 | } catch (error) { 15 | alert(error); 16 | } 17 | }, [history]); 18 | return ( 19 |
20 |

Sign up

21 |
22 | 26 | 30 | 31 |
32 |
33 | ); 34 | }; 35 | 36 | export default withRouter(SignUp); -------------------------------------------------------------------------------- /todo-react-firebase/src/Utils.js: -------------------------------------------------------------------------------- 1 | export default { 2 | pluralize: (count, word) => { 3 | return count === 1 ? word : word + 's'; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /todo-react-firebase/src/base.js: -------------------------------------------------------------------------------- 1 | import firebase from "firebase/app"; 2 | import "firebase/auth"; 3 | import config from "./config.json"; 4 | 5 | 6 | const app = firebase.initializeApp({ 7 | apiKey: config.apiKey, 8 | authDomain: config.authDomain, 9 | projectId: config.projectId, 10 | storageBucket: config.storageBucket, 11 | messagingSenderId: config.messagingSenderId, 12 | appId: config.appId 13 | }); 14 | 15 | 16 | export default app; 17 | -------------------------------------------------------------------------------- /todo-react-firebase/src/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "apiKey": "your-firebase-apiKey", 3 | "authDomain": "your-firebase-authDomain", 4 | "projectId": "your-firebase-projectId", 5 | "storageBucket": "your-firebase-storageBucket", 6 | "messagingSenderId": "your-firebase-messagingSenderId", 7 | "appId": "your-firebase-appId", 8 | "graphqlUrl": "your-graphql-endpoint" 9 | } 10 | -------------------------------------------------------------------------------- /todo-react-firebase/src/defs.js: -------------------------------------------------------------------------------- 1 | export default { 2 | ALL_TODOS: 'all', 3 | ACTIVE_TODOS: 'active', 4 | COMPLETED_TODOS: 'completed', 5 | } 6 | -------------------------------------------------------------------------------- /todo-react-firebase/src/history.js: -------------------------------------------------------------------------------- 1 | import { createBrowserHistory } from "history"; 2 | 3 | export default createBrowserHistory(); 4 | -------------------------------------------------------------------------------- /todo-react-firebase/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import 'todomvc-app-css/index.css' 4 | 5 | import {AuthProvider} from "./Auth"; 6 | 7 | ReactDOM.render( 8 | , 10 | document.getElementById("root") 11 | ); 12 | -------------------------------------------------------------------------------- /todo-react-firebase/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /todo-react-firebase/todo-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-react-firebase/todo-1.png -------------------------------------------------------------------------------- /todo-react-firebase/todo-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-react-firebase/todo-2.png -------------------------------------------------------------------------------- /todo-react-firebase/todo-graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgraph-io/graphql-sample-apps/527715638ab14310efdea23ca79a3c36df08f288/todo-react-firebase/todo-graph.png -------------------------------------------------------------------------------- /twitter-app/README.md: -------------------------------------------------------------------------------- 1 | ## Twitter App 2 | 3 | `schema.graphql` contains schema for the twitter app. 4 | 5 | The schema contains the following relationships: 6 | 7 | hashtag -> tweets -> user -> followers(remote endpoint) 8 | 9 | user -> tweets 10 | 11 | tweets -> user 12 | 13 | ## sample query for deep nester graph 14 | 15 | ``` 16 | query{ 17 | querySearchTweets{ 18 | text 19 | user{ 20 | screen_name 21 | followers{ 22 | users{ 23 | name 24 | } 25 | } 26 | } 27 | } 28 | } 29 | ``` 30 | 31 | ## To populate databsase 32 | 33 | go to seeder directory and change the following variable 34 | 35 | ``` 36 | hashtagName := "#rust" // populate the hash tag you want to scrape. 37 | flags.consumerKey = "key" // populate your consumer key 38 | flags.consumerSecret = "key" // populate your consumer secret. 39 | ``` 40 | 41 | ## Steps to populate 42 | 1) run dgraph instance 43 | 2) update the schema 44 | 3) run the seeder program -------------------------------------------------------------------------------- /twitter-app/schema.graphql: -------------------------------------------------------------------------------- 1 | type SearchTweets { 2 | id: ID! 3 | text: String! 4 | user: User 5 | hashtag: HashTag 6 | } 7 | 8 | type HashTag { 9 | id: ID! 10 | name: String! 11 | tweets: [SearchTweets] @hasInverse(field: hashtag) 12 | } 13 | 14 | type User { 15 | id: ID! 16 | screen_name: String! @id 17 | followers: Followers @custom(http:{ 18 | url: "https://api.twitter.com/1.1/followers/list.json?screen_name=$screen_name" 19 | method: "GET", 20 | forwardHeaders: ["Authorization"] 21 | }) 22 | tweets: [SearchTweets] @hasInverse(field: user) 23 | } 24 | 25 | type RemoteUser@remote { 26 | id: ID! 27 | name: String 28 | screen_name: String 29 | location: String 30 | description: String 31 | followers_count: Int 32 | statuses_count: Int 33 | friends_count: Int 34 | } 35 | 36 | type Followers@remote{ 37 | users: [RemoteUser] 38 | } -------------------------------------------------------------------------------- /twitter-app/seeder/go.mod: -------------------------------------------------------------------------------- 1 | module seeder 2 | 3 | go 1.14 4 | 5 | require ( 6 | github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f 7 | github.com/dghubble/go-twitter v0.0.0-20190719072343-39e5462e111f 8 | github.com/machinebox/graphql v0.2.2 9 | github.com/pkg/errors v0.9.1 // indirect 10 | golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d 11 | ) 12 | --------------------------------------------------------------------------------