.
4 |
5 | ## Setup the backend with Slash DgraphQL and use the schema below
6 |
7 | ```graphql
8 | type Message @withSubscription {
9 | id: ID!
10 | name: String!
11 | text: String!
12 | time: DateTime!
13 | }
14 | ```
15 |
16 | ## Setup the frontend by installing Node.js and cloning this repository
17 |
18 | Installing dependencies
19 |
20 | ```bash
21 | npm install @apollo/client @apollo/link-ws subscriptions-transport-ws graphql
22 | ```
23 |
24 | Steps to run
25 |
26 | ```bash
27 | npm install
28 | npm start
29 | ```
30 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/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-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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/chat-app-react/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | text-align: center;
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 | /* tr:nth-child(even) {background-color: #f2f2f2;} */
16 | tr:hover {background-color: #f5f5f5;}
17 |
18 | table {
19 | margin-left: auto;
20 | margin-right: auto;
21 | border-collapse: collapse;
22 | }
23 |
24 | th, td {
25 | border: 1px solid #cecfd5;
26 | padding: 10px 15px;
27 | }
28 |
--------------------------------------------------------------------------------
/dev-jokes/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.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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/chat-app-react/src/Query.js:
--------------------------------------------------------------------------------
1 | import { gql } from "@apollo/client";
2 |
3 | /* GraphQL Schema used for reference
4 | type Message @withSubscription {
5 | id: ID!
6 | name: String!
7 | text: String!
8 | time: DateTime!
9 | }
10 | */
11 |
12 | const SUBSCRIPTION_QUERY = gql`
13 | subscription {
14 | queryMessage(order: { desc: time }) {
15 | name
16 | text
17 | time
18 | }
19 | }
20 | `;
21 |
22 | const SEND_MESSAGE = gql`
23 | mutation sendMessage($name: String!, $text: String!, $time: DateTime!) {
24 | addMessage(input: [{ name: $name, text: $text, time: $time }]) {
25 | message {
26 | name
27 | text
28 | time
29 | }
30 | }
31 | }
32 | `;
33 |
34 | export { SUBSCRIPTION_QUERY, SEND_MESSAGE };
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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!
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/blog-post-app/blog-post-vue/src/components/Post.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
Title: {{ post.title }}
7 |
8 | by {{ post.author.name }}
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
30 |
--------------------------------------------------------------------------------
/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 | }
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/blog-post-app/src/components/Post.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
Title: {{ post.title }}
7 |
8 | by {{ post.author.name }}
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
31 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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;
--------------------------------------------------------------------------------
/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;
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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;
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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;
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/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 | }
--------------------------------------------------------------------------------
/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/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import { ApolloProvider } from '@apollo/client';
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 | import client from "./apollo-client";
10 |
11 | import * as serviceWorker from './serviceWorker';
12 |
13 | const theme = createMuiTheme(themes);
14 |
15 | ReactDOM.render(
16 |
17 |
18 |
19 |
20 | ,
21 | document.getElementById('root')
22 | );
23 |
24 | // If you want your app to work offline and load faster, you can change
25 | // unregister() to register() below. Note this comes with some pitfalls.
26 | // Learn more about service workers: https://bit.ly/CRA-PWA
27 | serviceWorker.unregister();
28 |
--------------------------------------------------------------------------------
/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 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/todo-app/todo-app-vue/src/TodoFooter.vue:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
--------------------------------------------------------------------------------
/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 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/dev-jokes/auth0_snippets/addUserRule.js:
--------------------------------------------------------------------------------
1 | // This rule makes a mutation to dgraph to add some users as moderators.
2 | function (user, context, callback) {
3 | const unirest = require("unirest");
4 | // Change the URL with your slash endpoint
5 | const slashEndpoint = "https://lazy-panda-8164.us-west-2.aws.cloud.dgraph.io/graphql";
6 | var req = unirest("POST", slashEndpoint);
7 | req.headers({
8 | "content-type": "application/json"
9 | });
10 |
11 | const username = user.email;
12 | const name = user.nickname;
13 | req.send(`{\"query\":\"mutation { addUser(input: [{ name: \\"${name}\\",username:\\"${username}\\" }]) { numUids }}\"}`);
14 | req.end(function (res) {
15 | console.log(JSON.stringify(res.body));
16 | if (res.body.errors) {
17 | console.log(JSON.stringify(res.body));
18 | if(res.body.errors) throw new Error(res.body.errors);
19 | }
20 | });
21 | return callback(null, user, context);
22 | }
--------------------------------------------------------------------------------
/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/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 | }
--------------------------------------------------------------------------------
/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-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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/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;
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/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-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 |
--------------------------------------------------------------------------------
/chat-app-react/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "chat",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@apollo/client": "^3.0.0-rc.12",
7 | "@apollo/link-ws": "^2.0.0-beta.3",
8 | "@testing-library/jest-dom": "^4.2.4",
9 | "@testing-library/react": "^9.5.0",
10 | "@testing-library/user-event": "^7.2.1",
11 | "graphql": "^15.3.0",
12 | "react": "^16.13.1",
13 | "react-dom": "^16.13.1",
14 | "react-scripts": "3.4.1",
15 | "subscriptions-transport-ws": "^0.9.16"
16 | },
17 | "scripts": {
18 | "start": "react-scripts start",
19 | "build": "react-scripts build",
20 | "test": "react-scripts test",
21 | "eject": "react-scripts eject"
22 | },
23 | "eslintConfig": {
24 | "extends": "react-app"
25 | },
26 | "browserslist": {
27 | "production": [
28 | ">0.2%",
29 | "not dead",
30 | "not op_mini all"
31 | ],
32 | "development": [
33 | "last 1 chrome version",
34 | "last 1 firefox version",
35 | "last 1 safari version"
36 | ]
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/chat-app-react/src/ApolloSetup.js:
--------------------------------------------------------------------------------
1 | import { ApolloClient } from '@apollo/client/core';
2 | import { getMainDefinition } from '@apollo/client/utilities';
3 | import { InMemoryCache } from '@apollo/client/cache';
4 | import { HttpLink, split } from '@apollo/client';
5 | import { WebSocketLink } from "@apollo/link-ws";
6 |
7 | const endpoint = process.env.REACT_APP_GRAPHQL_ENDPOINT;
8 |
9 | const wsLink = new WebSocketLink({
10 | uri: `wss://${endpoint}`,
11 | options: {
12 | reconnect: true
13 | }
14 | });
15 |
16 | const httpLink = new HttpLink({
17 | uri: `https://${endpoint}`
18 | });
19 |
20 | const link = split(
21 | // split based on operation type
22 | ({ query }) => {
23 | const definition = getMainDefinition(query);
24 | return (
25 | definition.kind === "OperationDefinition" &&
26 | definition.operation === "subscription"
27 | );
28 | },
29 | wsLink,
30 | httpLink
31 | );
32 |
33 | export default new ApolloClient({
34 | cache: new InMemoryCache(),
35 | link
36 | });
37 |
--------------------------------------------------------------------------------
/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 |
32 |
33 | );
34 | };
35 |
36 | export default withRouter(SignUp);
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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;
--------------------------------------------------------------------------------
/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/todo-nextjs-ssr/components/TodoList.js:
--------------------------------------------------------------------------------
1 | import { useSubscription, gql } from "@apollo/client";
2 | import { Card, Image } from "semantic-ui-react";
3 |
4 | const GET_TODOS = gql`
5 | subscription {
6 | queryTodo {
7 | title
8 | description
9 | completed
10 | }
11 | }
12 | `;
13 |
14 | const TodoList = () => {
15 | const { loading, error, data } = useSubscription(GET_TODOS);
16 |
17 | if (loading) return Loading...
;
18 | if (error) return Error :(
;
19 | return (
20 |
21 | {data.queryTodo.map(({ id, title, description, completed }) => (
22 |
23 |
28 |
29 | {title}
30 | {completed ? "Done" : "Pending"}
31 | {description}
32 |
33 |
34 | ))}
35 |
36 | );
37 | };
38 |
39 | export default TodoList;
40 |
--------------------------------------------------------------------------------
/todo-app/todo-nextjs-ssr/public/vercel.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/donors-app/src/App.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import logo from './logo.svg';
3 | import './App.css';
4 | import { Container, Navbar } from 'react-bootstrap';
5 | import { useQuery } from 'urql';
6 | import { SchoolItemFragment } from './gql/graphql';
7 | import Schools from './components/Schools';
8 |
9 | function App() {
10 | /*
11 | const [{ data, fetching, error }] = useQuery( {
12 | query: TopSchoolsDocument,
13 | variables: {
14 | first: 10
15 | }
16 | })
17 |
18 | var schools = new Array();
19 | data?.querySchool?.map((e,i) => e && schools.push(e));
20 | */
21 |
22 | return (
23 |
24 |
25 |
26 |
27 |
{' | '}Donors Application
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | );
41 | }
42 |
43 | export default App;
44 |
--------------------------------------------------------------------------------