Giter Site home page Giter Site logo

Comments (5)

yuzhi avatar yuzhi commented on May 8, 2024 2

The Users container needs to know that it should be getting an array.
Can you try replacing fragment on User with fragment on User @relay(plural:true)?

from relay.

Nutelac avatar Nutelac commented on May 8, 2024 1

Unfortunately, this does not works. It throws Invariant Violation: GraphQLFragmentPointer: Wrong plurality, single data ID supplied with plural fragment.. I'm pretty sure that this query returns array:

query UsersQuery {
  users {
    id
    name
  }
}

from relay.

yungsters avatar yungsters commented on May 8, 2024 1

The problem you're running into is the same one that several others have been filing issues about. Basically, fields on the root are treated specially and assumed to either:

  • Map to a single node (e.g. node(id: 123), me), or...
  • Map to an array of nodes (e.g. nodes(ids: [123, 456])).

Your users field does not have any arguments, so it is assumed to respond with a single record. For now, if you create a root object (e.g. viewer) and add a users field on it, this should work. However, @yuzhi also brought up the point that you might actually want users to be a connection instead of a plural field. (If you ever have hundreds of users, you might want to paginate instead of getting them all back.)

I'll write up a more comprehensive issue to explain what the problem is, why it exists, current workarounds, and future plans.

from relay.

Nutelac avatar Nutelac commented on May 8, 2024

Here is repo.

from relay.

yungsters avatar yungsters commented on May 8, 2024

See #112 for a better explanation.

from relay.

Related Issues (20)

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.