GithubHelp home page GithubHelp logo

Comments (15)

danstarns avatar danstarns commented on July 28, 2024 1

Not a bad idea, although I wouldn't say it's any more explicit than the current way of doing it. What if you wanted upserted... then you have to apply two directives?

type Movie {
    id: ID
    upsertedAt: DateTime! @CreatedDate @LastModifiedDate
}

from graphql.

Andy2003 avatar Andy2003 commented on July 28, 2024 1

I think we need to consider the size and surface area of the library, if we introduce lots and lots of directives for each use case; how will that be to document & remember?

You can define a partial schema containing all the frameworks types (like e.g. DeleteInfo) and directives, add it to your npm package the IDE will allow code completion and documentation for your types:

image

"""
some nice doc
"""
directive @CreatedDate on FIELD_DEFINITION

Additionally you can define where the user can place the directive.

Plus adding more directives restricts users in implementing there own.

come on...
but you can prefix all directives with neo4j

from graphql.

darrellwarde avatar darrellwarde commented on July 28, 2024 1

Just for your information @Andy2003, with this we're taking the direction:

directive @timestamp(operation: TimestampEvent! = UPSERT) on FIELD_DEFINITION
enum TimestampEvent{
  CREATE,
  UPDATE,
  UPSERT
}

That would mean if someone wanted a general timestamp of the last update or creation, they just use @timestamp. And then if someone wanted two separate create and update fields, they would have @timestamp(operation: CREATE) and @timestamp(operation: UPDATE).

from graphql.

danstarns avatar danstarns commented on July 28, 2024

Where do you see each directive mentioned being applied? On the type definition? Or a field?

from graphql.

Andy2003 avatar Andy2003 commented on July 28, 2024

on the field

from graphql.

Andy2003 avatar Andy2003 commented on July 28, 2024
type Movie {
    id: ID
    createdAt: DateTime! @CreatedDate
    updatedAt: DateTime! @LastModifiedDate
}

from graphql.

Andy2003 avatar Andy2003 commented on July 28, 2024

then you have to apply two directives?

Yes, this looks very familiar to me as a Java user :-)

from graphql.

darrellwarde avatar darrellwarde commented on July 28, 2024

Not a bad idea, although I wouldn't say it's any more explicit than the current way of doing it. What if you wanted upserted... then you have to apply two directives?

type Movie {
    id: ID
    upsertedAt: DateTime! @CreatedDate @LastModifiedDate
}

Personally not a fan of this at all, in my opinion would have to come up with a cleaner way of implementing this.

from graphql.

danstarns avatar danstarns commented on July 28, 2024

One could argue just make a @Upserted directive and jobs a gooden. I think we need to consider the size and surface area of the library, if we introduce lots and lots of directives for each use case; how will that be to document & remember? Plus adding more directives restricts users in implementing there own.

from graphql.

Andy2003 avatar Andy2003 commented on July 28, 2024

Personally not a fan of this at all, in my opinion would have to come up with a cleaner way of implementing this.

So if you stay with @autogenerate, you should at least make the operations argument an enum array.

from graphql.

darrellwarde avatar darrellwarde commented on July 28, 2024

I think we need to consider the size and surface area of the library, if we introduce lots and lots of directives for each use case; how will that be to document & remember?

You can define a partial schema containing all the frameworks types (like e.g. DeleteInfo) and directives, add it to your npm package the IDE will allow code completion and documentation for your types:

image

"""
some nice doc
"""
directive @CreatedDate on FIELD_DEFINITION

Additionally you can define where the user can place the directive.

Love this, code completion for our directives would be a game changer.

from graphql.

Andy2003 avatar Andy2003 commented on July 28, 2024

This is the reason, why I extracted the directives and made them "static". So the Intellij graphql plugin will scan the whole project for *.graphql files and provides you with code completion.

image

from graphql.

Andy2003 avatar Andy2003 commented on July 28, 2024

image
image

from graphql.

darrellwarde avatar darrellwarde commented on July 28, 2024

Yep, completely onboard with this, definitely going on the roadmap!

Time for me to relax for the evening. 😪 Thanks for all of the feedback on this, it's really valuable. Have a good weekend!

from graphql.

darrellwarde avatar darrellwarde commented on July 28, 2024

This has now been implemented and will be in the next release. In the end, the definition is as follows:

enum TimestampOperation {
    CREATE
    UPDATE
}

"""Instructs @neo4j/graphql to generate timestamps on particular events, which will be available as the value of the specified field."""
directive @timestamp(
    """Which events to generate timestamps on. Defaults to both create and update."""
    operations: [TimestampOperation!]! = [CREATE, UPDATE]
) on FIELD_DEFINITION

from graphql.

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.