This file contains hidden or 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 teamSchema = new Schema({ | |
| name: { | |
| type: String, | |
| required: 'name is required', | |
| }, | |
| tradeName: { | |
| type: String, | |
| required: 'trade name is required', | |
| }, | |
| taxId: { |
This file contains hidden or 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 mongoose from 'mongoose'; | |
| const { ObjectId } = mongoose.Schema.Types; | |
| const Schema = mongoose.Schema; | |
| const UserSchema = new Schema({ | |
| name: { | |
| type: String, | |
| required: 'name is required', | |
| }, |
This file contains hidden or 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 playerSchema = new Schema({ | |
| status: { | |
| type: Number | |
| }, | |
| name: { | |
| type: String, | |
| required: 'name is required', | |
| }, | |
| lastname: { | |
| type: String, |
This file contains hidden or 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 graphqlSettingsPerReq = async req => { | |
| const { user } = await getUser(req.header.authorization); | |
| return { | |
| graphiql: process.env.NODE_ENV !== 'production', | |
| schema, | |
| context: { | |
| user, | |
| req, | |
| dataloaders, |
This file contains hidden or 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
| export async function getUser (token) { | |
| if (!token) return { user: null } | |
| try { | |
| const decodedToken = jwt.verify(token.substring(4), jwtSecret) | |
| const user = await User.findOne({ _id: decodedToken.id }) | |
| return { | |
| user, |
This file contains hidden or 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
| export default new GraphQLObjectType({ | |
| name: 'Query', | |
| description: 'The root of all queries', | |
| fields: () => ({ | |
| me: { | |
| type: UserType, | |
| resolve: (root, args, context) => { | |
| if (!context.user) { | |
| return null; | |
| } |
This file contains hidden or 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
| if (isCalculating) { | |
| const biggestText = getBiggerTextWidth(); | |
| return <span ref={measuredRef}>{biggestText}</span>; | |
| } |
This file contains hidden or 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 getBiggerTextWidth = () => { | |
| return labels.reduce((acc, cur) => { | |
| if (cur.length >= acc.length) { | |
| return cur; | |
| } | |
| return acc; | |
| }, ''); | |
| }; |
This file contains hidden or 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 measuredRef = useCallback(node => { | |
| if (node !== null) { | |
| setWidth(node.getBoundingClientRect().width); | |
| } | |
| return setIsCalculating(false); | |
| }, []); |
OlderNewer