Using the following schema:
type Post @model
@auth(rules: [{allow: groups, groupsField: "groups"}]) {
id: ID!
title: String
groups: [String]
}
mutation createCategory { | |
__typename | |
createCategory(input: {name: "shoes"}) { | |
id | |
name | |
} | |
} | |
mutation createProduct { | |
__typename |
exports.handler = function (event, context) { //eslint-disable-line | |
const taxTable = { | |
NY: 8.49, CA: 8.56, OK: 8.92, FL: 7.05, | |
IL: 8.74, PA: 6.34, WA: 9.17, TX: 8.19 | |
} | |
let price | |
let taxRate | |
if (event.arguments) { | |
// graphql request |
type Category @model | |
@auth(rules: [ | |
{ allow: groups, groups: ["Admin"], operations: [create, update, delete] }, | |
{ allow: private, operations: [read] } | |
]) | |
{ | |
id: ID! | |
name: String! | |
products: [Product] @connection | |
} |
import React, { useState } from 'react'; | |
import './App.css'; | |
import { withAuthenticator } from 'aws-amplify-react' | |
import { Storage } from 'aws-amplify' | |
function App() { | |
const [image, updateImage] = useState({key: null, signedUrl: null}) | |
async function getImage() { |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Principal": "*", | |
"Action": "s3:GetObject", | |
"Resource": "arn:aws:s3:::gqlimages6c6fev-dev/public/images/thumbnails/*" | |
} | |
] |
Using the following schema:
type Post @model
@auth(rules: [{allow: groups, groupsField: "groups"}]) {
id: ID!
title: String
groups: [String]
}
readFile = async (filePath) => { | |
return new Promise((res, reject) => { | |
var request = new XMLHttpRequest(); | |
request.open("GET", filePath, true); | |
request.responseType = "arraybuffer"; | |
request.onload = _event => { res(request.response) } | |
request.onerror = err => { reject(err); }; | |
request.send(null); | |
}); | |
} |
After cloning & running yarn bootstrap
/ yarn build
of the whole package, the best way to develop locally is to link the individual package you’re working on and run lerna in watch mode.
For example if you clone Amplify and you want to make some changes for a PR, you’ll have a sample project and then link it:
# Run watch mode while editing (auth for example):
npx lerna exec --scope @aws-amplify/auth yarn link
npx lerna exec --scope @aws-amplify/auth tsc -- --watch
// Utils.js | |
// new util for RN File Source | |
export async function fileToRNArrayBuffer(uri) { | |
return new Promise((res, reject) => { | |
var request = new XMLHttpRequest(); | |
request.open("GET", uri, true); | |
request.responseType = "arraybuffer"; | |
request.onload = _event => { res(request.response) } | |
request.onerror = err => { reject(err); }; | |
request.send(null); |