Skip to content

Instantly share code, notes, and snippets.

View helielson's full-sized avatar

Helielson helielson

  • Indaband, Frontend Bahia
  • Salvador, Brazil
View GitHub Profile
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
import { useNavigationParam } from 'react-navigation-hooks';
import { graphql, usePreloadedQuery } from 'react-relay/hooks';
const query = graphql`
query TaskDetailQuery($nodeId: ID!) {
task: node(id: $nodeId) {
... on Task {
title
}
}
import RelayDefaultMissingFieldHandlers from 'relay-runtime/lib/handlers/RelayDefaultMissingFieldHandlers';
import missingHandlerByRefConcreteTypeField from './missingHandlerByRefConcreteTypeField';
const store = new Store(new RecordSource());
const network = Network.create(fetchQuery);
const environment = new Environment({
network,
store,
missingFieldHandlers: [
const missingHandlerByRefConcreteTypeField: MissingFieldHandler = {
kind: 'linked',
handle(field, _, argValues) {
try {
const argsString =
field.args && field.args.length
? `{${field.args.map(a => `"${a.name}":"${argValues[a.name]}"`).join(',')}}`
: null;
const idValue = [field.concreteType, argsString].filter(v => !!v).join(':');
const id = base64Encode('Event:{"eventId":1}');
const key = `${id}:title`;
const storeRecord = {
[key]: "My event",
};
{
"events": {
"edges": [{
"node": {
"eventId": 1,
"title": "My event"
}
}]
}
}
// ScreenBDetail
const ScreenBDetailQuery = graphql`
query ScreenBDetailQuery {
root {
event(id: $someId) {
title
}
}
}
`;
// ScreenB
const ScreenBQuery = graphql`
query ScreenBQuery {
root {
events(first: $first) {
edges {
node {
title
}
}
case 'store-or-network': {
shouldFetch = !hasFullQuery;
shouldAllowRender = canPartialRender;
break;
}
// https://github.com/facebook/relay/blob/66e747a68b8fac474fa44b4eb441c72c72daf89e/packages/relay-experimental/QueryResource.js#L392-L395
_traverse(node: NormalizationNode, dataID: DataID): void {
const status = this._mutator.getStatus(dataID);
if (status === UNKNOWN) {
this._handleMissing();
}
if (status === EXISTENT) {
this._traverseSelections(node.selections, dataID);
}
}