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 { forEachField } from 'graphql-tools'; | |
import { get } from 'lodash/fp'; | |
export default (schema: Object) => { | |
forEachField(schema, (field: Object) => { | |
if (field.authenticate) { | |
// eslint-disable-next-line no-param-reassign | |
field.resolve = (...args) => { | |
const [,, context] = args; |
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
### TIP 1 | |
Get list of transitive dependencies. | |
NOTE: Make sure the second tip is not set if you want to see the full result of this. | |
``` | |
$ cd android | |
$ ./gradlew :app:dependencies | |
``` | |
### TIP 2 |
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 createExpo from 'expobook'; | |
import Button from './components/button'; | |
const expobook = createExpo(); | |
expobook.add('My button', () => <Button>Hello World</Button>); | |
expobook.add('My other button', () => <Button>Hello World, again</Button>); | |
export default expobook.build(); |
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 csvToJson = csv => { | |
const [firstLine, ...lines] = csv.split('\n'); | |
return lines.map(line => | |
firstLine.split(',').reduce( | |
(curr, next, index) => ({ | |
...curr, | |
[next]: line.split(',')[index], | |
}), | |
{} | |
) |
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
################## | |
### config.yml ### | |
################## | |
version: 2 | |
jobs: | |
build: | |
docker: | |
- image: circleci/python:3.6 | |
steps: |
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 server = new ApolloServer({ | |
formatError, | |
resolvers, | |
typeDefs: SCHEMA, | |
engine: false, | |
tracing: true, | |
cacheControl: true, | |
subscriptions: { | |
onConnect: authSubscription |
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 Query { | |
getMyData: Data @authenticate | |
somePublicData: String | |
} | |
type Mutation { | |
updateAnItem(id: ID!, name: String!): Item @authenticate | |
} |
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 updateAnItem = (root, args) => { | |
return Item.update({ name: args.name }).where({ id: args.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
const updateAnItem = (root, args, ctx) => { | |
return Item.update({ name: args.name }).where({ id: args.id, userId: ctx.userId }); | |
}; |
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 { createRateLimitDirective } from 'graphql-rate-limit'; | |
const server = new ApolloServer({ | |
typeDefs: gql` | |
type Mutation { | |
# Limit to 10 per minute | |
login(email: String!, password: String!): String! @rateLimit(max: 10, window: 60000) | |
} | |
`, | |
resolvers: { |
OlderNewer