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
import { fromGlobalId } from 'graphql-relay'; | |
import { Model, Types } from 'mongoose'; | |
// returns an ObjectId given an param of unknown type | |
export const getObjectId = (target: string | Model<any> | Types.ObjectId): Types.ObjectId | null => { | |
if (target instanceof Types.ObjectId) { | |
return new Types.ObjectId(target.toString()); | |
} | |
if (typeof target === '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
import { usePrevious } from '@app/hooks'; | |
import { useEffect } from 'react'; | |
import ReactGA from 'react-ga'; | |
import { useLocation } from 'react-router-dom'; | |
export const usePageView = () => { | |
const location = useLocation(); | |
const lastLocation = usePrevious(location); |
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
BLOCKERS: | |
If you use react-native-fbads, it doesn't build on android 0.62. | |
Either wait fix or remove. | |
I've openned an issue already: https://github.com/callstack/react-native-fbads/issues/244 | |
Some libs are also giving the Error "Super expression must either be null or a function" | |
You should open an issue and look for a PR that fixes it, or fix it yourself. | |
Example of a PR fixing this issue: https://github.com/expo/react-native-action-sheet/pull/162 | |
To install a dep from a github PR, add to package.json: |
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
it('should call mutation properly', async () => { | |
// eslint-disable-next-line | |
const { debug, getByText, getByTestId } = render(<MyComponent />); | |
const customMockResolvers = { | |
...mockResolvers, | |
}; | |
const name = 'myName'; |
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
const UserType = new GraphQLObjectType<IUser, GraphQLContext>({ | |
name: 'User', | |
description: 'User data', | |
fields: () => ({ | |
id: globalIdField('User'), | |
...mongooseIDResolver, | |
name: { | |
type: GraphQLString, | |
resolve: user => user.name, | |
}, |
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
import { ROOT_ID } from 'relay-runtime'; | |
import { useRelayEnvironment } from 'react-relay/hooks'; | |
import { useLocation, useHistory } from 'react-router-dom'; | |
import { commitLocalUpdate } from 'react-relay' | |
import { useMutation } from 'relay-hooks/lib'; | |
import { AuthUserMutation } from 'mutations/AuthUserMutation'; | |
export const TOKEN_KEY = 'KEY'; |
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
// eslint-disable-next-line | |
import { mongooseLoader } from '@entria/graphql-mongoose-loader'; | |
import DataLoader from 'dataloader'; | |
import { ConnectionArguments } from 'graphql-relay'; | |
import { Model, Types } from 'mongoose'; | |
import { buildMongoConditionsFromFilters } from '@entria/graphql-mongo-helpers'; | |
import { validateContextUser } from './validateContextUser'; | |
import { withConnectionCursor } from './withConnectionCursor'; |
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
import { useEffect } from 'react'; | |
import { graphql, readInlineData } from 'react-relay'; | |
import { useHistory } from '../routing/useHistory'; | |
import { useAuth_user } from './__generated__/useAuth_user.graphql'; | |
const useAuthFragment = graphql` | |
fragment useAuth_user on User @inline { | |
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
let relayEnvironment = null; | |
export const initEnvironment = (records = {}) => { | |
const network = Network.create(cacheHandler); | |
const source = new RecordSource(records); | |
const store = new Store(source, { | |
// This property tells Relay to not immediately clear its cache when the user | |
// navigates around the app. Relay will hold onto the specified number of | |
// query results, allowing the user to return to recently visited pages |
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
import React from 'react' | |
import PropTypes from 'prop-types' | |
const Heading = ({children, cssClass, level}) => { | |
const Tag = `h${level}` | |
return <Tag className={cssClass}>{children}</Tag> | |
} | |
Heading.propTypes = { |