GraphQL: query by nested field reference/ID

Hey all, I’m trying fauna for the first time and I wanted to organize my data relying on the “import GraphQL schema” feature. I also wanted fauna to create some indexes automatically for some queries I’m going to need.
Here’s the schema I’m trying to create/import:

type User {
name: String!
externalId: Int! @unique

type Sell {
buyer: User!
seller: User!
time: Time!
description: String

type Query {
allSells: [Sell!]
sellsBySeller(seller: ID!): [Sell!]

that last query is what I can’t figure out how to write so it can auto generate it, or if it’s even possible. Basically I want to list all sells made by a given user, and I don’t know if I should specify a @relation or maybe embed the User type in the Sell type, or something else. I’ve tried all of these options and gotten different kinds of errors.

I understand I should be able to do this with custom resolvers, but I wanted fauna to auto generate it if possible.
Also, and if this is possible, my next step would be to try and do the same thing but querying by seller.externalId, what about that?

I’ve done things similar to this:

type User {
    name: String! @unique
    sales: [Transaction!] @relation(name: "transaction_seller")
    purchases: [Transaction!] @relation(name: "transaction_buyer")

type Transaction {
    seller: User! @relation(name: "transaction_seller")
    buyer: User! @relation(name: "transaction_buyer")
    description: String

Fauna will create a mutation called ‘createTransaction’. In your application code when you create transactions you do something like this:

createTransaction(data {
    description: "Slightly used bagel"
    seller: { connect: "48302708380" }
    buyer: { connect: "84038082378" }
1 Like

That’s exactly what I needed! Thank you so much :slight_smile: