Coder Social home page Coder Social logo

Comments (10)

tothandras avatar tothandras commented on June 23, 2024

@Dugnist You need to create another field. id is used by Relay and it encodes the resource type along with the mongoose _id.

from graffiti-mongoose.

Dugnist avatar Dugnist commented on June 23, 2024

@tothandras ok, as then i can create unique field or rewrite _id during create new document?

from graffiti-mongoose.

Dugnist avatar Dugnist commented on June 23, 2024

@tothandras i try use "unique: true" in mongo schema and it did not working...(

from graffiti-mongoose.

tothandras avatar tothandras commented on June 23, 2024

@Dugnist for what do you need a custom id?

from graffiti-mongoose.

tothandras avatar tothandras commented on June 23, 2024

does this work or not?

new Schema({
    identifier: { type: String, index: { unique: true } }
})

from graffiti-mongoose.

Dugnist avatar Dugnist commented on June 23, 2024

@tothandras i need to create a full object that include field "id" on the client-side and then push them on server...

from graffiti-mongoose.

tothandras avatar tothandras commented on June 23, 2024

@Dugnist hmmm.. why not just use the ids you get back when inserting objects with a mutation? so you can have the ids on the client side too for new objects

from graffiti-mongoose.

Dugnist avatar Dugnist commented on June 23, 2024

@tothandras yes - index: { unique: true } is working. Thank you. Maybe you know some trick how can circumvent restriction with "id" field? The policy of my project require creating unique id on the client...(

from graffiti-mongoose.

Dugnist avatar Dugnist commented on June 23, 2024

@tothandras unfortunately i cannot do any request with my custom field "ID" without default field "id"...(

This mutation not working... I know why and it sadly...(

mutation {
  updateDocument( input: {
    name: "Name of Document",
    ID : "123",
    clientMutationId: "1"
  }) {
    changedDocument {
      ID
    }
  }
}

from graffiti-mongoose.

tothandras avatar tothandras commented on June 23, 2024

@Dugnist To be honest I've never heard unique id and client side in the same sentence. :) As the user has full control over the sent object, you eventually need to validate it server side.
What you can try is to use a plural query with the ID and then you can get the actual id to do the mutation.. it's something

from graffiti-mongoose.

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.