Giter Site home page Giter Site logo

Comments (8)

bellini666 avatar bellini666 commented on July 17, 2024

Hey @gersmann ,

Hrm, I'm trying to replicate the issue here but it is working fine for me. The schema shows as not required and I can not send service at all to the input and it will work. It will not work if the field cannot be null though, for obvious reasons.

Can you provide more information regarding this? Like, the traceback itself, how are you doing the mutation, etc?

from strawberry-django-plus.

gersmann avatar gersmann commented on July 17, 2024

@bellini666 you're right, not sure how that schema came to be, I didn't reproduce the problem correctly. It happens when inheriting a base type, this should reproduce it:

@gql.django.input(ServiceInstance)
class ServiceInstancePartialInput(NodeInput):
    id: gql.ID
    service: Optional[OneToManyInput]
    key: Optional[str]

@gql.django.input(Connector)
class ConnectorPartialInput(ServiceInstancePartialInput):
    pass
@gql.type
class ServiceMutation:
    update_connector: ConnectorType = gql.django.update_mutation(ConnectorPartialInput)
{
  "data": null,
  "errors": [
    {
      "message": "Field 'ConnectorPartialInput.service' of required type 'OneToManyInput!' was not provided.",
      "locations": [
        {
          "line": 18,
          "column": 25
        }
      ],
      "path": null
    }
  ]
}

Stack:

edit: removed

from strawberry-django-plus.

gersmann avatar gersmann commented on July 17, 2024

Noticed that inheritance behaves a bit strange in general, for instance if case a Django foreign key relationship is inherited, it is represented by the generic DjangoModelType, but if it is defined directly on the child type, it is represented by the correct concrete GraphQL type.

from strawberry-django-plus.

bellini666 avatar bellini666 commented on July 17, 2024

Hey @gersmann ,

You are calling your types Partial, but you are using gql.django.input on them instead of gql.django.partial (or even gql.django.input(partial=True)). That may be the issue with it being required.

Noticed that inheritance behaves a bit strange in general, for instance if case a Django foreign key relationship is inherited, it is represented by the generic DjangoModelType, but if it is defined directly on the child type, it is represented by the correct concrete GraphQL type.

Don't know if I understood what you meant here... Could you provide an example of that too?

from strawberry-django-plus.

gersmann avatar gersmann commented on July 17, 2024

@bellini666

sorry for the screenshots, haven't been able to export the schema with django yet (apps aren't ready...)

So this definitiion:

@gql.django.type(Customer)
class CustomerType:
    id: gql.auto
    name: gql.auto


@gql.django.type(ServiceInstance)
class ServiceInstanceType:
    customer: CustomerType

@gql.django.type(Connector)
class ConnectorType(ServiceInstanceType):
    pass

@gql.type
class Query:
    service_instances: List[ServiceInstanceType] = gql.field()
    connectors: List[ConnectorType] = gql.field()

Gives me for ServiceInstanceType:
image

But for ConnectorType:
image

Thats what I meant this inheritance behaving a bit strange.

from strawberry-django-plus.

gersmann avatar gersmann commented on July 17, 2024

This here replicates the original issue, also seems like it is inheritance-related:

@gql.django.input(ServiceInstance)
class ServiceInstanceInput:
    service: Optional[OneToManyInput]


@gql.django.input(Connector)
class ConnectorInput(ServiceInstanceInput):
    updated_at: gql.auto


@strawberry.type
class Mutation:
    create_service_instance: ServiceInstanceType = gql.django.create_mutation(ServiceInstanceInput)
    create_connector: ConnectorType = gql.django.create_mutation(ConnectorInput)

ServiceInstanceInput:
image

ConnectorInput:
image

from strawberry-django-plus.

bellini666 avatar bellini666 commented on July 17, 2024

Hey @gersmann ,

Think I found the issue. Should be fixed in the release I'm doing right now. Please reopen this issue if it is not

from strawberry-django-plus.

gersmann avatar gersmann commented on July 17, 2024

@bellini666 Thanks a lot.

from strawberry-django-plus.

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.