Giter Club home page Giter Club logo

Comments (13)

visualcookie avatar visualcookie commented on July 26, 2024 1

Here's the dump of the current set-up without the jobs and teams collection.

directus.gz

UPDATE: Somehow I get a new GraphQL query for the article_translations collection.

query MyQuery {
  allDirectusArticleTranslation {
    nodes {
      article_id {
        id
      }
    }
  }
}

This is super weird. The query for article_translations shouldn't be there, but if I delete the status field from the unmanaged collection now languages and article_translations I won't be able to get anything. Shouldn't be the case.

UPDATE 2: Here's the output from the yarn run console.

yarn run v1.17.0
$ yarn develop
$ gatsby develop
success open and validate gatsby-configs - 0.005 s
success load plugins - 0.562 s
success onPreInit - 0.005 s
success initialize cache - 0.008 s
success copy gatsby files - 0.049 s
success onPreBootstrap - 0.014 s
GSD7: info Started logging for gatsby-source-directus7.
GSD7: info Directus data fetcher initializing...
GSD7: info targetStatus is: draft
GSD7: success Connected to Directus!
GSD7: success Logged in to Directus!
GSD7: info Fetching Directus file data...
GSD7: success Found 17 files from Directus.
GSD7: info Downloading Directus files to Gatsby build cache...
(node:28550) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
⠀
GSD7: success Downloaded all 17 files from Directus!
GSD7: info Fetching Directus Collection data...
GSD7: info Fetching Directus Items data...
GSD7: info Target status not matched for article_translations 1. Going through revisions
GSD7: info Status matched for jobs 1. Using item
GSD7: info Status matched for team 1. Using item
GSD7: info Status matched for team 2. Using item
GSD7: info Status matched for team 3. Using item
GSD7: info Status matched for team 4. Using item
GSD7: info Status matched for team 5. Using item
GSD7: info Status matched for team 6. Using item
GSD7: info Status matched for team 7. Using item
GSD7: info Status matched for team 8. Using item
GSD7: info Status matched for team 9. Using item
GSD7: info Status matched for team 10. Using item
GSD7: info Status matched for team 11. Using item
GSD7: info Status matched for team 12. Using item
GSD7: info Status matched for team 13. Using item
GSD7: info Status matched for team 14. Using item
GSD7: info Status matched for team 15. Using item
GSD7: info Target status not matched for languages 1. Going through revisions
GSD7: info Target status not matched for languages 2. Going through revisions
GSD7: info Status matched for articles 1. Using item
GSD7: warning No item of 1 in languages matched target status draft. This might lead to unexpected behavior!
GSD7: warning No item of 2 in languages matched target status draft. This might lead to unexpected behavior!
GSD7: warning No item of 1 in article_translations matched target status draft. This might lead to unexpected behavior!
GSD7: info Fetching Directus Relations data...
GSD7: success Retrieved all data from Directus!
GSD7: info Directus data processing starting...
GSD7: info Mapping Directus relations to Items...
GSD7: info Found Many-To-One relation: team -> jobs
GSD7: warning Missing One-To-Many relation in 'team'. The relation
GSD7: warning will be called 'jobs' in GraphQL as a best guess.
GSD7: info Found Many-To-One relation: articles -> article_translations
GSD7: info Found One-To-Many relation: article_translations -> articles
GSD7: info Cleaning junction collections...
GSD7: info Mapping Directus files to Items...
GSD7: info Mapping files for article_translations...
GSD7: info Mapping files for jobs...
GSD7: info Mapping files for team...
GSD7: info Generating GraphQL nodes...
GSD7: success All done!
GSD7: info Ended logging for gatsby-source-directus7.
success source and transform nodes - 4.203 s
warn Multiple node fields resolve to the same GraphQL field `DirectusJob.image` - [`image`, `image___NODE`]. Gatsby will use `image___NODE`.
warn Multiple node fields resolve to the same GraphQL field `DirectusTeam.avatar` - [`avatar`, `avatar___NODE`]. Gatsby will use `avatar___NODE`.
success building schema - 0.371 s
success createPages - 0.003 s
success createPagesStatefully - 0.093 s
success onPreExtractQueries - 0.003 s
success update schema - 0.094 s
success extract queries from components - 0.183 s
success run static queries - 1.996 s — 7/7 3.51 queries/second
success run page queries - 0.088 s — 36/36 420.84 queries/second
success write out page data - 0.005 s
success write out redirect data - 0.002 s
success Build manifest and related icons - 0.055 s
success onPostBootstrap - 0.063 s
⠀
info bootstrap finished - 10.398 s
⠀
 DONE  Compiled successfully in 4928ms 

from gatsby-source-directus7.

visualcookie avatar visualcookie commented on July 26, 2024 1

After removing the targetStatus and defaultStatus fields from the config and restarting with yarn start, it works without any errors and the translations field is now also included in allDirectusArticle.

from gatsby-source-directus7.

Jonesus avatar Jonesus commented on July 26, 2024

It should be possible as under the hood it's not really that different from a standard relation and I feel like I've had it work before, unfortunately I might not have time to look at it before next week but at least then I'll try to come up with something

from gatsby-source-directus7.

visualcookie avatar visualcookie commented on July 26, 2024

@Jonesus Nice. Yeah, I already tried to check GraphiQL, but could not find any query that could've done this.

from gatsby-source-directus7.

Jonesus avatar Jonesus commented on July 26, 2024

Hi! I tried the same setup:

Doc part to the setup: https://docs.directus.io/guides/relationships.html#translations

using the newest version of my plugin (0.7.1) and the newest version of Directus (App 7.5.0 and API 2.1.1) and it works flawlessly for me:
Screenshot from 2019-06-17 23-26-51

Do you think you could give me your database dump again? I'd need all the set up collections and also the directus_relations -collection

from gatsby-source-directus7.

visualcookie avatar visualcookie commented on July 26, 2024

Hey, sure!

That dump should get you covered regarding my current setup.

from gatsby-source-directus7.

Jonesus avatar Jonesus commented on July 26, 2024

Hey @visualcookie ! For some reason the dump you gave me was missing the translations-field in the Posts-collection as I would've expected it to have as following through the instructions given here. After I set up the field in the Posts as follows:

Screenshot from 2019-06-23 15-08-11
Screenshot from 2019-06-23 15-08-20
Screenshot from 2019-06-23 15-08-33

the translations show up in GraphiQL as they did on my test setup:

Screenshot from 2019-06-23 15-09-36

I didn't try out the file problem yet but I'll try digging into that too. If this configuration fixes your translations issue then awesome, and if you can reproduce the file thingy and provide me with a database dump of that problem too it would make the process quite a bit faster for me :)

from gatsby-source-directus7.

visualcookie avatar visualcookie commented on July 26, 2024

Finally had the time to continue. It's weird that I don't have the translations field for the query.

image

from gatsby-source-directus7.

Jonesus avatar Jonesus commented on July 26, 2024

Hey!

That one works for me out of the box too...

Screenshot from 2019-07-02 19-27-17

And my npm run start output:

> [email protected] develop /home/jonesus/code/gsd_dev
> gatsby develop

success open and validate gatsby-configs - 0.006 s
success load plugins - 0.394 s
success onPreInit - 0.008 s
success initialize cache - 0.023 s
success copy gatsby files - 0.021 s
success onPreBootstrap - 0.008 s
GSD7: info Started logging for gatsby-source-directus7.
GSD7: info Directus data fetcher initializing...
GSD7: info targetStatus is: draft
GSD7: success Connected to Directus!
GSD7: success Logged in to Directus!
GSD7: info Fetching Directus file data...
GSD7: success Found 0 files from Directus.
GSD7: info Downloading Directus files to Gatsby build cache...
GSD7: success Downloaded all 0 files from Directus!
GSD7: info Fetching Directus Collection data...
GSD7: info Fetching Directus Items data...
GSD7: info Status matched for languages 1. Using item
GSD7: info Status matched for languages 2. Using item
GSD7: info Status matched for articles 1. Using item
GSD7: info Status matched for article_translations 1. Using item
GSD7: info Status matched for article_translations 2. Using item
GSD7: info Fetching Directus Relations data...
GSD7: success Retrieved all data from Directus!
GSD7: info Directus data processing starting...
GSD7: info Mapping Directus relations to Items...
GSD7: info Found Many-To-One relation: team -> jobs
GSD7: warning Missing One-To-Many relation in 'team'. The relation
GSD7: warning will be called 'jobs' in GraphQL as a best guess.
GSD7: info Found Many-To-One relation: articles -> article_translations
GSD7: info Found One-To-Many relation: article_translations -> articles
GSD7: info Cleaning junction collections...
GSD7: info Mapping Directus files to Items...
GSD7: info Generating GraphQL nodes...
GSD7: success All done!
GSD7: info Ended logging for gatsby-source-directus7.
success source and transform nodes - 0.335 s
success building schema - 0.244 s
success createPages - 0.004 s
success createPagesStatefully - 0.043 s
success onPreExtractQueries - 0.005 s
success update schema - 0.033 s
success extract queries from components - 0.151 s
success write out requires - 0.005 s
success write out redirect data - 0.003 s
success Build manifest and related icons - 0.190 s
success onPostBootstrap - 0.204 s
⠀
info bootstrap finished - 3.581 s
⠀
success run static queries - 0.259 s — 3/3 12.15 queries/second
success run page queries - 0.078 s — 5/5 80.29 queries/second
success Generating image thumbnails — 6/6 - 0.435 s
 DONE  Compiled successfully in 4642ms

What versions of the packages are you running? My test config is gatsby-source-directus7 == 0.8.0, Gatsby == 2.10.0 and Directus suite == 190621A, I can't really figure out what's causing the disparity between our results...

Edit: It's most likely related to your gatsby-config.js settings with targetStatus and defaultStatus fields, let me investigate a bit further...

from gatsby-source-directus7.

Jonesus avatar Jonesus commented on July 26, 2024

Hey @visualcookie ! Could you paste your gatsby-source-directus7 config from gatsby-config.js? It seems according to your build output that your target status filters out all the items in Directus according to these lines:

GSD7: warning No item of 1 in languages matched target status draft. This might lead to unexpected behavior!
GSD7: warning No item of 2 in languages matched target status draft. This might lead to unexpected behavior!
GSD7: warning No item of 1 in article_translations matched target status draft. This might lead to unexpected behavior!

So changing either the config's targetStatus / defaultStatus or changing the statuses of items should make the correct nodes appear in GraphQL! I also happened to find a bug in the code fetching the items which might have caused unintended behavior in such cases, should be fixed in gatsby-source-directus 0.8.1.

from gatsby-source-directus7.

visualcookie avatar visualcookie commented on July 26, 2024

Hey @Jonesus. Sure, the config looks as followed:

module.exports = {
  siteMetadata: {
    title: `Gatsby Default Starter`,
    description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`,
    author: `@gatsbyjs`,
  },
  plugins: [
    `gatsby-plugin-flow`,
    `gatsby-plugin-react-helmet`,
    `gatsby-plugin-styled-components`,
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `images`,
        path: `${__dirname}/src/assets`,
      },
    },
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: `gatsby-starter-default`,
        short_name: `starter`,
        start_url: `/`,
        background_color: `#663399`,
        theme_color: `#663399`,
        display: `minimal-ui`,
        icon: `src/assets/browser-icon.png`,
      },
    },
    {
      resolve: `gatsby-plugin-module-resolver`,
      options: {
        root: `./src`,
        aliases: {
          components: `./components`,
          constants: `./constants`,
          i18n: `./i18n`,
          pages: `./pages`,
          styles: `./styles`,
          utils: `./utils`,
          assets: `./assets`,
          sections: `./sections`,
          templates: `./templates`,
          static: {
            root: `./public`,
            alias: `./static`,
          },
        },
      },
    },
    {
      resolve: `gatsby-plugin-intl`,
      options: {
        path: `${__dirname}/src/i18n`,
        languages: [`en`, `de`],
        defaultLanguage: `de`,
        redirect: true,
      },
    },
    {
      resolve: `gatsby-source-directus7`,
      options: {
        url: 'XXX',
        project: '_',
        email: 'XXX',
        password: 'XXX',
        targetStatus: 'draft',
        defaultStatus: 'published',
      },
    },
  ],
}

from gatsby-source-directus7.

Jonesus avatar Jonesus commented on July 26, 2024

That is interesting, I tried it with the same setup

targetStatus: 'draft',
defaultStatus: 'published',

And those work for me, the only way I managed to make it fail was with both of those being 'draft'... Those fields aren't required, so if you try removing them completely from the config how does the build output look like then?

from gatsby-source-directus7.

Jonesus avatar Jonesus commented on July 26, 2024

Great, I can't really figure out why it wouldn't work for you with the settings enabled as I can't reproduce the issue on my end, but if you feel you can manage without those features lets roll with this 👍

from gatsby-source-directus7.

Related Issues (15)

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.