GithubHelp home page GithubHelp logo

Question: TypeGraphQL uses functions to prevent circular dependencies-wouldn't this package's API suffer from the same problem? about typegql HOT 7 CLOSED

prismake avatar prismake commented on May 17, 2024
Question: TypeGraphQL uses functions to prevent circular dependencies-wouldn't this package's API suffer from the same problem?

from typegql.

Comments (7)

MichalLytek avatar MichalLytek commented on May 17, 2024 2

@capaj
I've proposed that a long time ago:
indigotech/graphql-schema-decorator#65 (comment)

But since that time our visions have splited - this is what @pie6k said:

image

So I think it's better when users have an ability to choose between library vs. framework and also the competition makes the development faster 😄

from typegql.

pie6k avatar pie6k commented on May 17, 2024 2

Thanks @capaj @19majkel94 .

Right, if you've got circular dependencies you'd have to use type lazy function like:

import { ObjectType, Field } from 'typegql';

@ObjectType()
class Car {
  @Field({ type: () => Person })
  owner() {
    return db.findPersonByCarId(this.id);
  }
  @Field() id: number;
}

@ObjectType()
class Person {
  @Field() id: number;
  @Field() name: string;
  @Field({ type: () => Car })
  car() {
    return db.findCarByOwnerId(this.id);
  }
}

Note it might be not needed anymore if typescript itself would make reflection metadata lazy in its core.

from typegql.

MichalLytek avatar MichalLytek commented on May 17, 2024

https://github.com/prismake/typegql/blob/6797a9ad0e0449e569e8f7c247d0ddc4c2c16f65/docs/explore/object-type-and-field.md#circular-type-references

from typegql.

capaj avatar capaj commented on May 17, 2024

cool, but wait do you contribute here too @19majkel94 ?

from typegql.

MichalLytek avatar MichalLytek commented on May 17, 2024

@capaj Nope, I just secretly watch all related projects and sometimes try to help in the name of the open source community 😉

from typegql.

capaj avatar capaj commented on May 17, 2024

@19majkel94 nice 🥇 I have to say It's a shame you don't work on the same project with @pie6k, because you two would make a great team-both of your libraries have very similar API and design goals. Seems like a waste of time to be working separately. But I guess in such an early stage of graphQL ecosystem more POCs isn't such a bad thing.

from typegql.

capaj avatar capaj commented on May 17, 2024

@19majkel94 great to hear what the difference really is. I can certainly appreciate both approaches-I am sure there are going to be apps well suited to both paradigms. Thanks for all the info! I am considering using one or the other in our API at Looop.co and these are exactly the things I need to know.

from typegql.

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.