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
onFileChange(e) { | |
const files = e.target.files || e.dataTransfer.files; | |
this.image = files[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
async createRecipe() { | |
const recipeObject = { | |
name: this.recipeName, | |
description: this.description, | |
difficultyLevel: this.difficultyLevel | |
? parseInt(this.difficultyLevel) | |
: 0, | |
image: this.image, | |
steps: this.stepsList, | |
averageTimeForCompletion: this.averageTime |
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
apollo: { | |
user: query.GET_USER_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
import gql from "graphql-tag"; | |
// user object pointing to loginUser to make the return response pretty | |
export const LOGIN_QUERY = gql` | |
mutation LoginUser($input: LoginUser!) { | |
user: loginUser(input: $input) { | |
token | |
} | |
} | |
`; |
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 Vue from 'vue'; | |
import VueApollo from "vue-apollo"; | |
import apolloUploadClient from "apollo-upload-client" | |
import { InMemoryCache } from "apollo-cache-inmemory"; | |
import { ApolloClient } from "apollo-client"; | |
import { setContext } from "apollo-link-context"; | |
Vue.use(VueApollo); |
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 Mutation { | |
createUser(email: String!, name: String!, password: String) | |
} |
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 createRecipe = async (root, { input }, { user }) => { | |
throwErrorIfUserNotAuthenticated(user); | |
// bring out the image from input for file processing | |
const { image, ...recipeObject } = await input; | |
let url = ""; | |
if (image) { | |
const result = await uploadFile(image); | |
url = result.url; |
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 { ApolloServer, gql } from 'apollo-server-express'; | |
import merge from 'lodash.merge' | |
import { userType, userResolvers } from './resources/user'; | |
import { recipeType, recipeResolvers } from './resources/recipe'; | |
import { fileType } from './resources/file'; | |
const typeDefs = gql`${userType}${recipeType}${fileType}`; | |
export const graphQLRouter = new ApolloServer( |
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
setMiddleware(app); | |
const path = '/recipe' | |
graphQLRouter.applyMiddleware({ app, path}); |
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 cloudinary from "cloudinary"; | |
import streamToBuffer from "stream-to-buffer"; | |
cloudinary.config({ | |
cloud_name: process.env.CLOUDINARY_CLOUD_NAME, | |
api_key: process.env.CLOUDINARY_API_KEY, | |
api_secret: process.env.CLOUDINARY_API_SECRET | |
}); | |
export const uploadFile = async file => { |
NewerOlder