Gatsby: [gatsby-source-wordpress] No localFile field on images in ACF fields

Created on 17 Oct 2017  ·  37Comments  ·  Source: gatsbyjs/gatsby

I was using the wordpress example site to work out how to use Sharp and got it working fine with allWordpressWpMedia or any wordpress Media query but on ACF it does not work in the same way. localFile just doesn't appear as an option in the graphql schema for ACF image fields. That seems to be the way it is being done in the example.

Example query below:

acf {
  collaboration {
    image {
      url
      localFile {
        id
      }
    }
    copy
  }
}
{
  "errors": [
    {
      "message": "Cannot query field \"localFile\" on type \"image_2\".",
      "locations": [
        {
          "line": 22,
          "column": 11
        }
      ]
    }
  ]
}

I'm wondering if this could be due to the same issue as my previous ticket when ACF fields couldn't be queried if some pages/posts didn't have them.

help wanted

Most helpful comment

For me post_parent = 0 solved it

UPDATE wp_posts SET post_parent = 0 WHERE post_type = 'attachment'

All 37 comments

It's hard to say without seeing a working example of this problem. Could you create a small site reproducing this problem and push it to Github that we could play with?

FWIW, this is the exact setup on the using-wordpress example site https://github.com/gatsbyjs/gatsby/blob/6cec4281cc9e20712f9ce72f7320c27ccaa2f5fb/examples/using-wordpress/src/templates/post.js#L76

@KyleAMathews here you go. This is using all the same versions as on my main project but I have just created a shell wordpress install. Just need to install wordpress via composer and point a virtual host at it. I have included the query I ran in the readme

I don't have composer running on my machine :-) Could you put the wordpress on a free host somewhere?

Also, feel free to take a crack at solving the issue yourself — check out the data in .cache/redux-state.json also if there's any files downloaded to .cache/gatsby-source-filesystem/.

This is where files are downloaded https://github.com/gatsbyjs/gatsby/blob/644f131db4f30bb8c2940a08dbfc4f07384c9464/packages/gatsby-source-wordpress/src/normalize.js#L307

Perhaps ACF has multiple ways of creating file attachments where we're only handling media?

@KyleAMathews I haven't really got time to be setting up hosting. I've committed everything to the repo so all you need to do is point a virtual host at it and setup and import database.

It is downloading the media files from acf fields to .cache/gatsby-source-filesystem/ but just doesn't seem to generate a reference to the local file in graphQL so there is no way to use the local image.

Also it seems to be generated correctly in redux-state.json (this is from the demo I put together for you guys):

"97c01a7a-4a9c-5fb4-a5cf-9cd50ae5cc86": {
      "wordpress_id": 20,
      "date": "2017-10-18T10:37:54.000Z",
      "guid": "http://demowordpressapi.local/wp-content/uploads/2017/10/cat.jpeg",
      "modified": "2017-10-18T10:37:58.000Z",
      "slug": "cat",
      "status": "inherit",
      "type": "attachment",
      "link": "http://demowordpressapi.local/about/cat/",
      "title": "cat",
      "comment_status": "open",
      "ping_status": "closed",
      "template": "",
      "meta": [],
      "description": "<p class=\"attachment\"><a href='http://demowordpressapi.local/wp-content/uploads/2017/10/cat.jpeg'><img width=\"300\" height=\"200\" src=\"http://demowordpressapi.local/wp-content/uploads/2017/10/cat-300x200.jpeg\" class=\"attachment-medium size-medium\" alt=\"\" srcset=\"http://demowordpressapi.local/wp-content/uploads/2017/10/cat-300x200.jpeg 300w, http://demowordpressapi.local/wp-content/uploads/2017/10/cat.jpeg 640w\" sizes=\"(max-width: 300px) 100vw, 300px\" /></a></p>\n",
      "caption": "",
      "alt_text": "",
      "media_type": "image",
      "mime_type": "image/jpeg",
      "media_details": {
        "width": 640,
        "height": 427,
        "file": "2017/10/cat.jpeg",
        "image_meta": {
          "aperture": "0",
          "credit": "",
          "camera": "",
          "caption": "",
          "created_timestamp": "0",
          "copyright": "",
          "focal_length": "0",
          "iso": "0",
          "shutter_speed": "0",
          "title": "",
          "orientation": "0",
          "keywords": []
        }
      },
      "post": 6,
      "source_url": "http://demowordpressapi.local/wp-content/uploads/2017/10/cat.jpeg",
      "_links": {
        "self": [
          {
            "href": "http://demowordpressapi.local/wp-json/wp/v2/media/20"
          }
        ],
        "collection": [
          {
            "href": "http://demowordpressapi.local/wp-json/wp/v2/media"
          }
        ],
        "about": [
          {
            "href": "http://demowordpressapi.local/wp-json/wp/v2/types/attachment"
          }
        ],
        "author": [
          {
            "embeddable": true,
            "href": "http://demowordpressapi.local/wp-json/wp/v2/users/1"
          }
        ],
        "replies": [
          {
            "embeddable": true,
            "href": "http://demowordpressapi.local/wp-json/wp/v2/comments?post=20"
          }
        ]
      },
      "id": "97c01a7a-4a9c-5fb4-a5cf-9cd50ae5cc86",
      "author___NODE": "ec1fb3e3-d897-5549-b5f6-72b358fbbe83",
      "localFile___NODE": "/Users/gary/DEVELOPMENT/acf-localfile-demo/.cache/gatsby-source-filesystem/b06517fb31d7c6c6ba874a381de8baa0.jpeg absPath of file",
      "children": [],
      "parent": null,
      "internal": {
        "type": "wordpress__wp_media",
        "contentDigest": "a1990108226cb75875a50ea8a4b05813",
        "owner": "gatsby-source-wordpress"
      }
    },

That appears to have the localFile mapping but it does not show in graphiql

I have the same issue, if there's no WP site up by tomorrow I can put a non-working example up for you.. unfortunately can't do it until tomorrow though 👍

Cool, so...

Gatsby: https://github.com/chrisgeary92/gatsby-wp-acf-media-issue
WP-API: https://deployasaurus.wpengine.com/wp-json/wp/v2/pages

Example query:

{
  allWordpressPage {
    edges {
      node {
        id
        featured_media {
          localFile {
            size
          }
        }
        acf {
          screenshot {
            wordpress_id
          }
        }
      }
    }
  }
}

You can't access localFile on acf.screenshot, but you can (for example) on featured_media.

If you need anything more, just let me know :)

@chrisgeary92 that's awesome thanks for sorting that out! :)

As of yet, fields named featured_media with the Post ID as a number and any field name with a Picture Post Object are supported.

We could extend the naming conventions to a greater number of field names that would be reserved for photos, like image, photo, picture, ...

I am running into this too at the moment... Installed everything new, still no localFile Node :(

@flmuel does the WordPress example site work for you?

@KyleAMathews yes the example works...

no local file for me
screenshot 2018-01-07 14 26 06
only for the example
screenshot 2018-01-07 14 26 38

Does your WordPress site have attached files? Gatsby dynamically creates the schemas from your data source(s).

Do you mean by attached files the media files that are connected with the acf fields? If yes, than I can confirm your question... The acf image fields are Media-Urls and not Objects or Ids.

Tried a kindy hacky alternative: I have placed the same images that are connected with the fields in WordPress in the Gatsby static folder. Now I am requiring the right image with "directory" + node->acf->image->slug + ".jpg"

It works and builds, but I do not like this solution... Netlify does not like this either and terminates the build process after:

Error: Module not found: Error: Cannot resolve 'file' or 'directory' ../static  /images in /opt/build/repo/src/templates
  resolve file
  resolve directory
    /opt/build/repo/src/static/images doesn't exist

Netlify works now, was an issue with yarn and sharp I think ... npm did the thing...
https://quirky-stonebraker-88058d.netlify.com/

but no localFile for me yet :(

So I have tracked this problem further down...
Example works, other WP Sites works as well - WP Sites with Basic Auth does not work...
So I console logged some vars in the compiled create-remote-file-node.js in gatsby-source-filesystem. The result was: everything fine (filenames were created, etc.) until

responseStream = got.stream(url, { headers });

something after this broke...
So I looked up the got package which needs auth options
Then I added another log before downloadProgress:

responseStream.on(`request`, function (pro) {
  console.log(pro);
});

which gave me this for each file:

ClientRequest {
  domain: null,
  _events: 
   { response: { [Function: bound onceWrapper] listener: [Function] },
     error: { [Function: bound onceWrapper] listener: [Function] } },
  _eventsCount: 2,
  _maxListeners: undefined,
  output: [],
  outputEncodings: [],
  outputCallbacks: [],
  outputSize: 0,
  writable: true,
  _last: true,
  upgrading: false,
  chunkedEncoding: false,
  shouldKeepAlive: false,
  useChunkedEncodingByDefault: false,
  sendDate: false,
  _removedConnection: false,
  _removedContLen: false,
  _removedTE: false,
  _contentLength: null,
  _hasBody: true,
  _trailer: '',
  finished: false,
  _headerSent: false,
  socket: 
   TLSSocket {
     _tlsOptions: 
      { pipe: false,
        secureContext: [SecureContext],
        isServer: false,
        requestCert: true,
        rejectUnauthorized: true,
        session: <Buffer 30 82 06 50 02 01 01 02 02 03 03 04 02 c0 2f 04 20 70 89 20 e1 ae c4 a3 ba b2 18 34 e0 aa 43 fc ef e2 49 40 c4 f1 bc 15 56 81 d8 aa 58 f1 28 26 5d 04 ... >,
        NPNProtocols: undefined,
        ALPNProtocols: undefined,
        requestOCSP: undefined },
     _secureEstablished: false,
     _securePending: false,
     _newSessionPending: false,
     _controlReleased: true,
     _SNICallback: null,
     servername: null,
     npnProtocol: null,
     alpnProtocol: null,
     authorized: false,
     authorizationError: null,
     encrypted: true,
     _events: 
      { close: [Array],
        end: [Array],
        finish: [Function: onSocketFinish],
        _socketEnd: [Function: onSocketEnd],
        secureConnect: [Function],
        connect: [Array],
        secure: [Function: onConnectSecure],
        free: [Function: onFree],
        agentRemove: [Function: onRemove],
        drain: [Function: ondrain],
        error: [Function: socketErrorListener],
        data: [Function: socketOnData] },
     _eventsCount: 12,
     connecting: true,
     _hadError: false,
     _handle: 
      TLSWrap {
        _parent: [TCP],
        _parentWrap: undefined,
        _secureContext: [SecureContext],
        reading: false,
        owner: [Circular],
        onread: [Function: onread],
        writeQueueSize: 1,
        onhandshakestart: [Function: noop],
        onhandshakedone: [Function: bound ],
        onocspresponse: [Function: onocspresponse],
        onerror: [Function: onerror] },
     _parent: null,
     _host: 'flmueller001.dev.360vier.net',
     _readableState: 
      ReadableState {
        objectMode: false,
        highWaterMark: 16384,
        buffer: [BufferList],
        length: 0,
        pipes: null,
        pipesCount: 0,
        flowing: true,
        ended: false,
        endEmitted: false,
        reading: true,
        sync: false,
        needReadable: true,
        emittedReadable: false,
        readableListening: false,
        resumeScheduled: false,
        destroyed: false,
        defaultEncoding: 'utf8',
        awaitDrain: 0,
        readingMore: false,
        decoder: null,
        encoding: null },
     readable: true,
     domain: null,
     _maxListeners: undefined,
     _writableState: 
      WritableState {
        objectMode: false,
        highWaterMark: 16384,
        finalCalled: false,
        needDrain: false,
        ending: false,
        ended: false,
        finished: false,
        destroyed: false,
        decodeStrings: false,
        defaultEncoding: 'utf8',
        length: 0,
        writing: false,
        corked: 0,
        sync: true,
        bufferProcessing: false,
        onwrite: [Function: bound onwrite],
        writecb: null,
        writelen: 0,
        bufferedRequest: null,
        lastBufferedRequest: null,
        pendingcb: 0,
        prefinished: false,
        errorEmitted: false,
        bufferedRequestCount: 0,
        corkedRequestsFree: [Object] },
     writable: true,
     allowHalfOpen: false,
     _bytesDispatched: 0,
     _sockname: null,
     _pendingData: null,
     _pendingEncoding: '',
     server: undefined,
     _server: null,
     ssl: 
      TLSWrap {
        _parent: [TCP],
        _parentWrap: undefined,
        _secureContext: [SecureContext],
        reading: false,
        owner: [Circular],
        onread: [Function: onread],
        writeQueueSize: 1,
        onhandshakestart: [Function: noop],
        onhandshakedone: [Function: bound ],
        onocspresponse: [Function: onocspresponse],
        onerror: [Function: onerror] },
     _requestCert: true,
     _rejectUnauthorized: true,
     parser: 
      HTTPParser {
        '0': [Function: parserOnHeaders],
        '1': [Function: parserOnHeadersComplete],
        '2': [Function: parserOnBody],
        '3': [Function: parserOnMessageComplete],
        '4': null,
        _headers: [],
        _url: '',
        _consumed: false,
        socket: [Circular],
        incoming: null,
        outgoing: [Circular],
        maxHeaderPairs: 2000,
        onIncoming: [Function: parserOnIncomingClient] },
     _httpMessage: [Circular],
     read: [Function],
     _consuming: true,
     [Symbol(res)]: 
      TLSWrap {
        _parent: [TCP],
        _parentWrap: undefined,
        _secureContext: [SecureContext],
        reading: false,
        owner: [Circular],
        onread: [Function: onread],
        writeQueueSize: 1,
        onhandshakestart: [Function: noop],
        onhandshakedone: [Function: bound ],
        onocspresponse: [Function: onocspresponse],
        onerror: [Function: onerror] },
     [Symbol(asyncId)]: 2510,
     [Symbol(bytesRead)]: 0,
     [Symbol(connect-options)]: 
      { rejectUnauthorized: true,
        ciphers: 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA',
        checkServerIdentity: [Function: checkServerIdentity],
        minDHSize: 1024,
        servername: 'flmueller001.dev.360vier.net',
        _defaultAgent: [Agent],
        path: null,
        retries: [Function],
        decompress: true,
        useElectronNet: true,
        protocol: 'https:',
        slashes: true,
        auth: null,
        host: 'flmueller001.dev.360vier.net',
        port: 443,
        hostname: 'flmueller001.dev.360vier.net',
        hash: null,
        search: null,
        query: null,
        pathname: '/wp-content/uploads/2018/01/test14.jpg',
        href: 'https://flmueller001.dev.360vier.net/wp-content/uploads/2018/01/test14.jpg',
        headers: [Object],
        method: 'GET',
        followRedirect: true,
        _agentKey: 'flmueller001.dev.360vier.net:443::::::::::',
        encoding: null,
        session: <Buffer 30 82 06 50 02 01 01 02 02 03 03 04 02 c0 2f 04 20 70 89 20 e1 ae c4 a3 ba b2 18 34 e0 aa 43 fc ef e2 49 40 c4 f1 bc 15 56 81 d8 aa 58 f1 28 26 5d 04 ... >,
        singleUse: true } },
  connection: 
   TLSSocket {
     _tlsOptions: 
      { pipe: false,
        secureContext: [SecureContext],
        isServer: false,
        requestCert: true,
        rejectUnauthorized: true,
        session: <Buffer 30 82 06 50 02 01 01 02 02 03 03 04 02 c0 2f 04 20 70 89 20 e1 ae c4 a3 ba b2 18 34 e0 aa 43 fc ef e2 49 40 c4 f1 bc 15 56 81 d8 aa 58 f1 28 26 5d 04 ... >,
        NPNProtocols: undefined,
        ALPNProtocols: undefined,
        requestOCSP: undefined },
     _secureEstablished: false,
     _securePending: false,
     _newSessionPending: false,
     _controlReleased: true,
     _SNICallback: null,
     servername: null,
     npnProtocol: null,
     alpnProtocol: null,
     authorized: false,
     authorizationError: null,
     encrypted: true,
     _events: 
      { close: [Array],
        end: [Array],
        finish: [Function: onSocketFinish],
        _socketEnd: [Function: onSocketEnd],
        secureConnect: [Function],
        connect: [Array],
        secure: [Function: onConnectSecure],
        free: [Function: onFree],
        agentRemove: [Function: onRemove],
        drain: [Function: ondrain],
        error: [Function: socketErrorListener],
        data: [Function: socketOnData] },
     _eventsCount: 12,
     connecting: true,
     _hadError: false,
     _handle: 
      TLSWrap {
        _parent: [TCP],
        _parentWrap: undefined,
        _secureContext: [SecureContext],
        reading: false,
        owner: [Circular],
        onread: [Function: onread],
        writeQueueSize: 1,
        onhandshakestart: [Function: noop],
        onhandshakedone: [Function: bound ],
        onocspresponse: [Function: onocspresponse],
        onerror: [Function: onerror] },
     _parent: null,
     _host: 'flmueller001.dev.360vier.net',
     _readableState: 
      ReadableState {
        objectMode: false,
        highWaterMark: 16384,
        buffer: [BufferList],
        length: 0,
        pipes: null,
        pipesCount: 0,
        flowing: true,
        ended: false,
        endEmitted: false,
        reading: true,
        sync: false,
        needReadable: true,
        emittedReadable: false,
        readableListening: false,
        resumeScheduled: false,
        destroyed: false,
        defaultEncoding: 'utf8',
        awaitDrain: 0,
        readingMore: false,
        decoder: null,
        encoding: null },
     readable: true,
     domain: null,
     _maxListeners: undefined,
     _writableState: 
      WritableState {
        objectMode: false,
        highWaterMark: 16384,
        finalCalled: false,
        needDrain: false,
        ending: false,
        ended: false,
        finished: false,
        destroyed: false,
        decodeStrings: false,
        defaultEncoding: 'utf8',
        length: 0,
        writing: false,
        corked: 0,
        sync: true,
        bufferProcessing: false,
        onwrite: [Function: bound onwrite],
        writecb: null,
        writelen: 0,
        bufferedRequest: null,
        lastBufferedRequest: null,
        pendingcb: 0,
        prefinished: false,
        errorEmitted: false,
        bufferedRequestCount: 0,
        corkedRequestsFree: [Object] },
     writable: true,
     allowHalfOpen: false,
     _bytesDispatched: 0,
     _sockname: null,
     _pendingData: null,
     _pendingEncoding: '',
     server: undefined,
     _server: null,
     ssl: 
      TLSWrap {
        _parent: [TCP],
        _parentWrap: undefined,
        _secureContext: [SecureContext],
        reading: false,
        owner: [Circular],
        onread: [Function: onread],
        writeQueueSize: 1,
        onhandshakestart: [Function: noop],
        onhandshakedone: [Function: bound ],
        onocspresponse: [Function: onocspresponse],
        onerror: [Function: onerror] },
     _requestCert: true,
     _rejectUnauthorized: true,
     parser: 
      HTTPParser {
        '0': [Function: parserOnHeaders],
        '1': [Function: parserOnHeadersComplete],
        '2': [Function: parserOnBody],
        '3': [Function: parserOnMessageComplete],
        '4': null,
        _headers: [],
        _url: '',
        _consumed: false,
        socket: [Circular],
        incoming: null,
        outgoing: [Circular],
        maxHeaderPairs: 2000,
        onIncoming: [Function: parserOnIncomingClient] },
     _httpMessage: [Circular],
     read: [Function],
     _consuming: true,
     [Symbol(res)]: 
      TLSWrap {
        _parent: [TCP],
        _parentWrap: undefined,
        _secureContext: [SecureContext],
        reading: false,
        owner: [Circular],
        onread: [Function: onread],
        writeQueueSize: 1,
        onhandshakestart: [Function: noop],
        onhandshakedone: [Function: bound ],
        onocspresponse: [Function: onocspresponse],
        onerror: [Function: onerror] },
     [Symbol(asyncId)]: 2510,
     [Symbol(bytesRead)]: 0,
     [Symbol(connect-options)]: 
      { rejectUnauthorized: true,
        ciphers: 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA',
        checkServerIdentity: [Function: checkServerIdentity],
        minDHSize: 1024,
        servername: 'flmueller001.dev.360vier.net',
        _defaultAgent: [Agent],
        path: null,
        retries: [Function],
        decompress: true,
        useElectronNet: true,
        protocol: 'https:',
        slashes: true,
        auth: null,
        host: 'flmueller001.dev.360vier.net',
        port: 443,
        hostname: 'flmueller001.dev.360vier.net',
        hash: null,
        search: null,
        query: null,
        pathname: '/wp-content/uploads/2018/01/test14.jpg',
        href: 'https://flmueller001.dev.360vier.net/wp-content/uploads/2018/01/test14.jpg',
        headers: [Object],
        method: 'GET',
        followRedirect: true,
        _agentKey: 'flmueller001.dev.360vier.net:443::::::::::',
        encoding: null,
        session: <Buffer 30 82 06 50 02 01 01 02 02 03 03 04 02 c0 2f 04 20 70 89 20 e1 ae c4 a3 ba b2 18 34 e0 aa 43 fc ef e2 49 40 c4 f1 bc 15 56 81 d8 aa 58 f1 28 26 5d 04 ... >,
        singleUse: true } },
  _header: null,
  _onPendingData: [Function: noopPendingOutput],
  agent: 
   Agent {
     domain: null,
     _events: { free: [Function] },
     _eventsCount: 1,
     _maxListeners: undefined,
     defaultPort: 443,
     protocol: 'https:',
     options: { path: null },
     requests: {},
     sockets: { 'flmueller001.dev.360vier.net:443::::::::::': [Array] },
     freeSockets: {},
     keepAliveMsecs: 1000,
     keepAlive: false,
     maxSockets: Infinity,
     maxFreeSockets: 256,
     maxCachedSessions: 100,
     _sessionCache: { map: [Object], list: [Array] } },
  socketPath: undefined,
  timeout: undefined,
  method: 'GET',
  path: '/wp-content/uploads/2018/01/test14.jpg',
  _ended: false,
  res: null,
  aborted: undefined,
  timeoutCb: null,
  upgradeOrConnect: false,
  parser: 
   HTTPParser {
     '0': [Function: parserOnHeaders],
     '1': [Function: parserOnHeadersComplete],
     '2': [Function: parserOnBody],
     '3': [Function: parserOnMessageComplete],
     '4': null,
     _headers: [],
     _url: '',
     _consumed: false,
     socket: 
      TLSSocket {
        _tlsOptions: [Object],
        _secureEstablished: false,
        _securePending: false,
        _newSessionPending: false,
        _controlReleased: true,
        _SNICallback: null,
        servername: null,
        npnProtocol: null,
        alpnProtocol: null,
        authorized: false,
        authorizationError: null,
        encrypted: true,
        _events: [Object],
        _eventsCount: 12,
        connecting: true,
        _hadError: false,
        _handle: [TLSWrap],
        _parent: null,
        _host: 'flmueller001.dev.360vier.net',
        _readableState: [ReadableState],
        readable: true,
        domain: null,
        _maxListeners: undefined,
        _writableState: [WritableState],
        writable: true,
        allowHalfOpen: false,
        _bytesDispatched: 0,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: [TLSWrap],
        _requestCert: true,
        _rejectUnauthorized: true,
        parser: [Circular],
        _httpMessage: [Circular],
        read: [Function],
        _consuming: true,
        [Symbol(res)]: [TLSWrap],
        [Symbol(asyncId)]: 2510,
        [Symbol(bytesRead)]: 0,
        [Symbol(connect-options)]: [Object] },
     incoming: null,
     outgoing: [Circular],
     maxHeaderPairs: 2000,
     onIncoming: [Function: parserOnIncomingClient] },
  maxHeadersCount: null,
  [Symbol(outHeadersKey)]: 
   { 'user-agent': 
      [ 'user-agent',
        'got/7.1.0 (https://github.com/sindresorhus/got)' ],
     'accept-encoding': [ 'accept-encoding', 'gzip,deflate' ],
     host: [ 'Host', 'flmueller001.dev.360vier.net' ] } }

You can see that the output says "auth: null" - so I really think thats the matter of my issue (maybe not linked to this acf issue)...
I dont know how to fix this... but I have an idea: the headers variable which is transfered to the stream func of got is empty - maybe you have to put auth options there

Ahhhhh! So we need to pass auth headers to createRemoteFileNode!

Could you work on a PR passing the right auth headers to got?

I dont know how...
I think you have to pass "_auth" from gatsby-node.js to normalize.js to create-remote-file-node.js, but then I have no idea how to pass this to got :(

The wordpress auth instructions will need translated to HTTP headers similar to what's done in https://github.com/gatsbyjs/gatsby/blob/2bda70e3dd2b32499ee3fe9838dcd74fd570ace3/packages/gatsby-source-wordpress/src/fetch.js

create-remote-file-node.js would need the ability to take an object of headers.

Basic Auth fixed!

I'm starting to experience this on a public API - no basic auth. How should I start to track it down?

GraphQL Error There was an error while compiling your site's GraphQL queries.
  Invariant Violation: GraphQLParser: Unknown field `localFile` on type `slideImage_4`. Source: document `HomepageQuery` file: `GraphQL request`.

The acf image fields are Media-Urls and not Objects or Ids.

Try the Link acf type, or anything that can send an image Object.

@bkonkle Please create a new issue

@crgeary @KyleAMathews @garytokyo if this is at all still relevant, I think I figured out the root cause:

https://github.com/gatsbyjs/gatsby/issues/6273#issuecomment-406007006

@Khristophor added troubleshooting guide that addresses this issue in https://github.com/gatsbyjs/gatsby/pull/6807, so I'll close it. Feel free to re-open or open new issue if following new docs doesn't fix issue for You

For me post_parent = 0 solved it

UPDATE wp_posts SET post_parent = 0 WHERE post_type = 'attachment'

For me post_parent = 0 solved it

UPDATE wp_posts SET post_parent = 0 WHERE post_type = 'attachment'

Thanks, this help me on my issue!

Somebody know how to create a filter on WordPress when the user upload one photo type attachment the post_parent with value 0 by default?

Cheers!

Thank you @MWalid. That fixed it for now. :)

@lpluispacheco did you find a solution for the filter already?

EDIT: no I was wrong. I just have the problem again.

The WP-Plugin https://de.wordpress.org/plugins/media-library-assistant/ offers the feature to bulk set post_parent=0 within the Wordpress admin UI. @pieh Maybe it is useful to readers of your troubleshooting section.

@lauritowal Same here, for me it just comes up during the night time, but I don't see any interesting issue in my server logs. I will call my hoster, maybe it is related to resources.

Hi @radscheit For me using
GATSBY_CONCURRENT_DOWNLOAD=8 gatsby develop
or GATSBY_CONCURRENT_DOWNLOAD=8 gatsby build
fixed the problem. The host couldn't handle too many file requests at once from Gatsby. Just play around with the number.

Hi @radscheit For me using
GATSBY_CONCURRENT_DOWNLOAD=8 gatsby develop
fixed the problem. The host couldn't handle too many file requests at once from Gatsby. Just play around with the number.

@lauritowal Thank you very much, saved my life! :)

@radscheit

The WP-Plugin https://de.wordpress.org/plugins/media-library-assistant/ offers the feature to bulk set post_parent=0 within the Wordpress admin UI. @pieh Maybe it is useful to readers of your troubleshooting section.

Stupid question.. But how? :D

@lauritowal

  1. Install and activate the plugin
  2. Navigate to Media > Assistant
  3. Select the items you want to change and choose Edit in the bulk action dropdown
  4. Now choose a new parent id and voilá

Screenshot 2020-02-08 at 10 09 57

Did it help you?

GATSBY_CONCURRENT_DOWNLOAD=8 gatsby develop works for me.

Was this page helpful?
0 / 5 - 0 ratings