Coder Social home page Coder Social logo

Comments (10)

mmahalwy avatar mmahalwy commented on August 15, 2024 1

Woohoo! Fixed! Thanks a bunch for this!

from pothos.

mmahalwy avatar mmahalwy commented on August 15, 2024

Happening because of circular dependencies.

from pothos.

hayes avatar hayes commented on August 15, 2024

Interesting. This path should only get called when creating a (different) error. It is trying to create a name for a ref which hasn't been implemented, but the ref is undefined. My guess would be some sort of circular import causing undefined to be passed as a ref because the file it was imported from hasn't run. Can't tell for sure what's causing it from that stack trace.

from pothos.

hayes avatar hayes commented on August 15, 2024

Error message in this case should be better, and I should probably just have a runtime check to disallow undefined as ref

from pothos.

mmahalwy avatar mmahalwy commented on August 15, 2024

Once I moved the objects into their own files, this error went away. I do think it's circular import is the problem.

from pothos.

hayes avatar hayes commented on August 15, 2024

How were the problematic refs being used? Anything inside a fields function should alread get deferred to allow circular references.

from pothos.

hayes avatar hayes commented on August 15, 2024

Actually, I think I see how this could still happen. I'm on a road trip, but will work on a fix soon

from pothos.

mmahalwy avatar mmahalwy commented on August 15, 2024

No worries. I was able to replicate it with recursive inputs:

export const ApplicationFieldConfigInput = builder
  .inputRef<ApplicationFieldConfig>('ApplicationFieldConfigInput')
  .implement({
    fields: (t) => ({
      name: t.string({ required: true }),
      label: t.string({ required: true }),
      type: t.field({ required: true, type: ApplicationFieldConfigTypeEnum }),
      fieldPath: t.string({}),
      fieldHandlers: t.field({
        required: true,
        type: [ApplicationFieldConfigFieldHandlerEnum],
      }),
      options: t.stringList({ required: true }),
      modelPath: t.string({}),
      docspringPath: t.string({}),
      visibleIf: t.string({}),
      requiredIf: t.string({}),
      validations: t.string({}),
      defaultRequired: t.boolean({ defaultValue: false }),
      defaultShow: t.boolean({ defaultValue: true }),
      defaultLocked: t.boolean({ defaultValue: false }),
      children: t.field({ required: true, type: [ApplicationFieldConfigInput] }),
    }),
  });

Also recursive on object:

export const ApplicationFieldConfigObject: ObjectRef<ApplicationFieldConfig> = builder
  .objectRef<ApplicationFieldConfig>('ApplicationFieldConfig')
  .implement({
    fields: (t) => ({
      name: t.exposeString('name', {}),
      label: t.exposeString('label', {}),
      type: t.expose('type', { type: ApplicationFieldConfigTypeEnum }),
      fieldPath: t.exposeString('fieldPath', { nullable: true }),
      fieldHandlers: t.expose('fieldHandlers', {
        type: [ApplicationFieldConfigFieldHandlerEnum],
      }),
      options: t.exposeStringList('options', {}),
      modelPath: t.exposeString('modelPath', { nullable: true }),
      docspringPath: t.exposeString('docspringPath', { nullable: true }),
      visibleIf: t.exposeString('visibleIf', { nullable: true }),
      requiredIf: t.exposeString('requiredIf', { nullable: true }),
      validations: t.exposeString('validations', { nullable: true }),
      defaultRequired: t.exposeBoolean('defaultRequired', { nullable: true }),
      defaultShow: t.exposeBoolean('defaultShow', { nullable: true }),
      defaultLocked: t.exposeBoolean('defaultLocked', { nullable: true }),
      // children: t.expose('children', { type: [ApplicationFieldConfigObject] }),
    }),
  });

from pothos.

hayes avatar hayes commented on August 15, 2024

Pushed a new version that should help with these. There was a bit of a regression here, but added a test specifically for recursive imports.

from pothos.

hayes avatar hayes commented on August 15, 2024

I think my recursive inputs split the implement step into a separate statement which is why they were not failing

from pothos.

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.