- Brief introduction to ReScript
- Motivation for untagged variants
- High-level overview of the proposal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow | |
import * as React from 'react'; | |
import { QueryRenderer, graphql } from 'react-relay'; | |
import { environment } from '../config/createRelayEnvironment'; | |
import type { AppQueryResponse } from './__generated__/AppQuery.graphql'; | |
const query = graphql` | |
query AppQuery { | |
viewer { | |
id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow | |
import * as React from 'react'; | |
import { queryMock } from '../../__testUtils__/queryMock'; // Or wherever your queryMock is located | |
import { App } from '../App'; | |
import { render, wait } from 'react-testing-library'; | |
describe('App', () => { | |
it('should render the current user count', async () => { | |
/** | |
* App fetches the query AppQuery. Here, we mock all requests for that query. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow | |
import { graphql, createPaginationContainer } from 'react-relay'; | |
import type { UserPetsList_user } from './__generated__/UserPetsList_user.graphql'; | |
import * as React from 'react'; | |
import SinglePet from './SinglePet'; | |
type Props = {| | |
relay: { | |
hasMore: () => boolean, | |
loadMore(pageSize: number, callback: ?(error: ?Error) => void): ?Object, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// collectConnectionNodes.js - Extracts and filters all nodes from a connection and returns it in a list, preserving the type information. | |
// @flow | |
export function collectConnectionNodes<T>( | |
connectionObj: ?{ | |
+edges: ?$ReadOnlyArray<?{ | |
+node: ?T | |
}> | |
} | |
): $ReadOnlyArray<T> { | |
if (connectionObj && connectionObj.edges && connectionObj.edges.length > 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type User { | |
id: ID! | |
name: String! | |
} | |
type Group { | |
id: ID! | |
name: String! | |
school: School! | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = [ | |
"and", | |
"as", | |
"asr", | |
"assert", | |
"begin", | |
"class", | |
"constraint", | |
"do", | |
"while", |
TypeScript:
/**
* This Fetch API interface allows you to perform various actions on HTTP
* request and response headers. These actions include retrieving, setting,
* adding to, and removing. A Headers object has an associated header list,
* which is initially empty and consists of zero or more name and value
* pairs.
*
* You can add to this using methods like append()