Skip to content

Instantly share code, notes, and snippets.

View dabit3's full-sized avatar
🎡
probably nothing

Nader Dabit dabit3

🎡
probably nothing
View GitHub Profile
@dabit3
dabit3 / schema.graphql
Created March 3, 2020 07:48
Real time message board schema
type Message @model {
id: ID!
title: String!
color: String
image: String
createdAt: String
}
@dabit3
dabit3 / schema.graphql
Created March 1, 2020 22:18
GraphQL Schema for many to many relationships with AWS Amplify
type Stage @model
@auth(rules: [
{ allow: public, provider: iam, operations: [read] },
{ allow: groups, groups: ["Admin"] }
]) {
id: ID!
name: String!
performances: [Performance] @connection(keyName: "byStageId", fields: ["id"])
}
@dabit3
dabit3 / downloadimage.js
Created February 26, 2020 13:16
Downloading image to local file system in Gatsby
// utils/downloadImage.js
import fs from 'fs'
import axios from 'axios'
import path from 'path'
function getImageKey(url) {
const split = url.split('/')
const key = split[split.length - 1]
const keyItems = key.split('?')
const imageKey = keyItems[0]
@dabit3
dabit3 / amplify-api.ssh
Created February 14, 2020 17:54
CLI flow for Amplify Auth multi-auth
? Please select from one of the below mentioned services: GraphQL
? Provide API name: ampdemo
? Choose the default authorization type for the API Amazon Cognito User Pool
Use a Cognito user pool configured as a part of this project.
? Do you want to configure advanced settings for the GraphQL API Yes, I want to make some additional changes.
? Configure additional auth types? Yes
? Choose the additional authorization types you want to configure for the API API key
API key configuration
? Enter a description for the API key: read
? After how many days from now the API key should expire (1-365): 200
@dabit3
dabit3 / schema.graphql
Last active February 15, 2020 17:15
How to build a serverless blog back end in one tweet with @awsamplify
type Blog @model
@auth(rules: [
{ allow: groups, groups: ["Admin"] }, { allow: public, operations: [read] }
]) {
id: ID!
name: String!
posts: [Post] @connection(name: "BlogPosts")
}
type Post @model
@auth(rules: [
@dabit3
dabit3 / info.plist
Created December 2, 2019 14:30
Example React Native Xcode info.plist with redirect
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>RNAuth</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
@dabit3
dabit3 / AndroidManifest.xml
Created December 2, 2019 14:28
Example React Native Android Manifest with redirect
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rnauth">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
@dabit3
dabit3 / post.md
Created November 21, 2019 02:35
post

Thanks to Richard Threlkeld and Attila Hajdrik for their help writing this article.

How to implement a real-world & comprehensive data model covering 17 different access patterns using GraphQL, AWS Amplify, and a NoSQL database (Amazon DynamoDB).


At the core of most applications is one thing: the data. Easily being able to, and understanding how to, model and access data in your app allows you to focus on delivering core features and business value instead of architecting and re-architecting your back end.

This is usually not an easy task, and requires a lot of thought. Part of getting this right is understanding the relationships between different types of data and how to make them work together.

@dabit3
dabit3 / schema.graphql
Created November 20, 2019 17:13
17 Access Patterns with GraphQL and AWS Amplify
type Order @model
@key(name: "byCustomerByStatusByDate", fields: ["customerID", "status", "date"])
@key(name: "byCustomerByDate", fields: ["customerID", "date"])
@key(name: "byRepresentativebyDate", fields: ["accountRepresentativeID", "date"])
@key(name: "byProduct", fields: ["productID", "id"])
{
id: ID!
customerID: ID!
accountRepresentativeID: ID!
productID: ID!
@dabit3
dabit3 / schema.graphql
Created October 11, 2019 19:58
Ecommerce schema without authorization rules
type Category @model {
id: ID!
name: String!
products: [Product] @connection
}
type Product @model {
id: ID!
name: String!
price: Float!