Giter VIP home page Giter VIP logo

Comments (9)

adriaanbalt avatar adriaanbalt commented on May 28, 2024

A bit of digging led me to this.. haven't tried it yet but I'm thinking of doing this instead. https://stackoverflow.com/questions/42775668/firebase-cloud-functions-multipart-form-data

from express-multipart-file-parser.

cristovao-trevisan avatar cristovao-trevisan commented on May 28, 2024

It seem it's an issue with the apollo server (I never used GraphQL before). Reading the docs (here) it seems there is no need to use any extra express middleware for file upload.
Also found this article that says you'll need to install the graphql-upload middleware.

As said at the stackoverflow question you linked, you could upload your file using the firebase web api and them send the path to your server. This is not ideal though

from express-multipart-file-parser.

cristovao-trevisan avatar cristovao-trevisan commented on May 28, 2024

Let me know if you get anywhere with this 😃

from express-multipart-file-parser.

adriaanbalt avatar adriaanbalt commented on May 28, 2024

I'll try that extra graphql-upload middleware you mentioned and let you know.

I stumbled across using createUploadLink here https://github.com/jaydenseric/apollo-upload-client although it isn't clear

Here is how I am setting up Apollo Client using the link attribute along with above server code:

import React from 'react'
import ReactDOM from 'react-dom'
import { ApolloProvider } from 'react-apollo'
import { ApolloClient } from 'apollo-client'
import { InMemoryCache } from 'apollo-cache-inmemory'
import { createUploadLink } from 'apollo-upload-client'
import { Provider } from 'react-redux'
import store, { history } from './Store'
import { ConnectedRouter } from 'react-router-redux'
import App from './App'
import registerServiceWorker from './lib/serviceWorker'
import './index.scss'
import { GRAPHQL_URL} from './constants/graphql'

const uploadLink = createUploadLink({
    uri: GRAPHQL_URL, // Apollo Server is served from port 4000
    headers: {
        "keep-alive": "true"
    }
})
const apolloCache = new InMemoryCache()

const client = new ApolloClient({
    cache: apolloCache,
    link: uploadLink,
    uri: GRAPHQL_URL,
});

ReactDOM.render(
    <ApolloProvider client={client}>
        <Provider store={store}>
            <ConnectedRouter history={history}>
                <App />
            </ConnectedRouter>
        </Provider>
    </ApolloProvider>,
    document.getElementById('root')
)
registerServiceWorker()

In your opinion, why is the stackoverflow question I linked "not ideal though"?

from express-multipart-file-parser.

cristovao-trevisan avatar cristovao-trevisan commented on May 28, 2024

from express-multipart-file-parser.

adriaanbalt avatar adriaanbalt commented on May 28, 2024

I agree with your assessment, initially my goal was to send a mutation over Firebase Cloud Function to GraphQL including some textual information along with a File (could be base64). The file would be uploaded to Firebase Storage and upon completion would be stored within Firebase Firestore (possibly using a Transaction to manage concurrency but I'm still debating this). Does this approach sound correct to you?

I also ran into this approach which shows that including uploads as a property on ApolloServer should be sufficient to use without the graphqlUploadExpress middleware, which I'm doing as you can see above.

PS: Do you suggest an alternative file storage? S3? Although this doesn't solve my issue with sending multipart/form-data over Cloud Functions to GraphQL because I'll still need to do that regardless of where store.

from express-multipart-file-parser.

cristovao-trevisan avatar cristovao-trevisan commented on May 28, 2024

from express-multipart-file-parser.

cristovao-trevisan avatar cristovao-trevisan commented on May 28, 2024

Closing as explained in the referenced issue (and possible solution)

from express-multipart-file-parser.

kurtabela avatar kurtabela commented on May 28, 2024

Did you ever solve this issue?

from express-multipart-file-parser.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.