Giter Site home page Giter Site logo

Customize ID behavior about houdini HOT 3 CLOSED

houdinigraphql avatar houdinigraphql commented on July 20, 2024
Customize ID behavior

from houdini.

Comments (3)

AlecAivazis avatar AlecAivazis commented on July 20, 2024

I've started working on this in a branch and need a place to hold onto some thoughts:

  • a single type could have multiple keys that are used together to form a record's ID
  • the node query used by refetches should be configurable to allow for specific queries that look up a value.

My current thinking for the API:

config  = {
    defaultKeys: ['_id'], 
    types: { 
        User: { 
            keys: ['email'],
            // not quite sure what to call this 
            refetch: {
                queryField: 'user',
                arguments: (user) => {email: user.email}
            },
        }
    }
}

from houdini.

lyle avatar lyle commented on July 20, 2024

My Vote...

I like the idea of the defaultKeys - not sure of the name... it might be better to call it defaultKeyField: '_id' as I think the default should only be a single.

And for entity key I would go with keyFields

config  = {
    defaultKeyField: '_id', 
    types: { 
        User: { 
            keyFields: ['email'],
            // not quite sure what to call this 
            refetch: {
                queryField: 'user',
                arguments: (user) => {email: user.email}
            },
        }
    }
}

from houdini.

AlecAivazis avatar AlecAivazis commented on July 20, 2024

Thanks for the input @lyle! I'm also unsure about the names. I was hoping that "key" implied "keyField" but I guess if a user is coming up to a config file for the first time it might not be totally clear. I'll think on it some more.

Do you have any ideas for what I could use instead of "refetch"? In case it wasn't clear from the example, that object configures the query that the cache uses to support things like paginated fragments. For any object that implements the Node interface, that object would take the default value:

{
    //...
    refetch: { 
        queryField: 'node',
        arguments: node => ({ id: node.id })
    }
}

edit: I just realized I named the internal function that looks up the keys for a field keyFieldsForType() so i guess I agree with you subconsciously 🤦

from houdini.

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.