question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error on self reference field on resolve type

See original GitHub issue

Hello guys,

So I`m trying to access self field using root on my objectType, but I cannot do this, because typescript complains that field doesn’t exists.

How can I solve that problem ? image

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
mandadocommented, Apr 21, 2021

nice! I’ll try to apply something like this!, thank you so much!

0reactions
otrebucommented, Apr 20, 2021

There could be two different types.

  • The types that represent the shape of the data in your database
  • The types that represent the graphQL schema.

Sometimes they are the same, but most times they are at least a bit different.

Here is an example:


export const Property = objectType({
  name: "Property",
  definition(t) {
    t.implements(Node);
    t.string("name");
    t.nonNull.field("user", {
      type: User,
      resolve(root, args, context) {
        if (!root.userId) {
          throw new Error("Id is needed to request posts");
        }
        return context.db.post.findMany({
          where: {
            post: {
              userId: root.userId,
            },
          },
        });
      },
    });
  },
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

JSON.NET Error Self referencing loop detected for type
The fix is to ignore loop references and not to serialize them. This behaviour is specified in JsonSerializerSettings .
Read more >
SELF-REFERENCE Error on Trigger - Salesforce Developers
I'm trying to create a trigger on Opportunities that will create a new account when a box on the opportunity is checked, then...
Read more >
Reference field type - Product Documentation | ServiceNow
A reference field stores a reference to a field on another table. For example, the Caller field on the Incident table is a...
Read more >
[JDK-8027941] javac fails with "self-reference in initializer ...
Bug - A problem which impairs or prevents the functions of the product. JDK-8025762 8.3.3: Clarify that a field cannot be referenced in...
Read more >
Modules: Packages | Node.js v19.3.0 Documentation
Package authors should include the "type" field, even in packages where all sources are ... Self-referencing is available only if package.json has "exports" ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found