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.

Feature request: way to require only_fields

See original GitHub issue

There doesn’t seem to be a way to enforce only_fields on DjangoObjectTypes. This is a serious security issue, since fields all default to accessible, including Django’s automatically created reverse relation fields.

I tried to introspect this value, but it gets erased at class creation time. We only end up with MyType._meta.fields, which is a value computed from several inputs including only_fields. Possible solutions:

  • Copy only_fields onto _meta
  • Don’t delete the Meta attribute from the class in SubclassWithMeta
  • Official support for requiring only_fields, in the form of a configuration setting

Related: #516

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jkimbocommented, Jun 12, 2019

@reverie https://github.com/graphql-python/graphene/pull/1007

Also your code above can be a bit cleaner by using the typemap from the schema directly (when the above PR has been merged):

def enforce_only_fields(schema):
	types = schema.get_type_map()
	for _, t in types.items():
		if issubclass(t.graphene_type, DjangoObjectType):
			assert t.graphene_type.Meta.only_fields
1reaction
jkimbocommented, Jun 12, 2019

Right I get you now. I’m not 100% sure why the Meta class gets deleted either to be honest. I’ll raise a PR in the Graphene repo and see if it gets anywhere.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Feature Request: Apply styles to read-only fields - ServiceNow
Solved: I was recently informed by Now Support that UI styles cannot be applied to read-only fields, and for this 7-year-old known issue, ......
Read more >
How to handle "can you add just a few more fields" type of ...
Very commonly we have feature requests for fields that only one customer wants. This, at best, clutters the application's code. Often when we...
Read more >
Feature Requests: What are they and how to manage them
Feature requests are a form of product feedback you may frequently encounter as a SaaS product manager. They typically come in the form...
Read more >
How To Manage Feature Requests [Template included]
This guide will teach you everything about feature requests – how to process them, manage them, respond to them, prioritize them – so...
Read more >
Read only ticket field for agents - Zendesk help
I would assume that a read only field for agents would need a method to ... PLEASE HONOR THIS FEATURE REQUEST. this is...
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