Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL fixes: handling for BigIntegerField (ASNField) and ContentType #430

Merged
merged 5 commits into from
May 12, 2021

Conversation

glennmatthews
Copy link
Contributor

Fixes: #428

For fields of type BigIntegerField (currently, AFAIK, only used as our subclass ASNField), use a custom scalar type that allows arbitrarily large integer values. This pattern will probably fail for values over 2^53ish since that is the limit supported by JavaScript, but as ASNField only allows numbers up to 2^32-1, that's a non-issue at this time.

Verified in GraphiQL that large ASN values are accepted as query parameters and are also permissible in the returned data:

image

image

image

Added regression test coverage as well.

@glennmatthews glennmatthews changed the title Use custom GraphQL scalar type for BigIntegerField (ASNField) GraphQL fixes: handling for BigIntegerField (ASNField) and ContentType May 11, 2021
@glennmatthews
Copy link
Contributor Author

Second commit fixes another GraphQL issue: because the built-in ContentType model naturally isn't decorated with @extras_features("graphql") it's not covered by our automatic generation of DjangoObjectType definitions. As a result, fields that referenced ContentType were being omitted from GraphQL. Adding an explicit type definition fixes this:

image

@glennmatthews
Copy link
Contributor Author

One more fix: enable the IPAddress.assigned_object field. This is a GenericForeignKey field, which graphene-django does not know how to automatically handle. Since it can point to either an Interface or a VMInterface, this field needs to be defined as a Union type, which we previously had no examples of in our code base. It does work quite nicely now:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GraphQL error on ASN > 2^31-1
2 participants