Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class category(models.Model):
- QUESTION = 'Q'
- SOLUTION = 'S'
- UNKNOWN = 'U'
- CATEGORY_CHOICE = (
- ('quiz', (
- (QUESTION, 'Question'),
- (SOLUTION, 'Solution'),
- )
- ),
- (UNKNOWN, 'Unknown'),
- )
- name = models.CharField(max_length=1, choices=CATEGORY_CHOICE)
- image = models.ImageField(upload_to='uploads/category/', default='anonymous.jpg')
- class Query(graphene.AbstractType):
- category = graphene.Field(categoryType, id=graphene.Int())
- def resolve_category(self, info, **kwargs):
- id = kwargs.get('id')
- if id is not None:
- return models.category.objects.get(pk=id)
- return None
- class Query(graphene.ObjectType, schema.Query):
- pass
- schema = graphene.Schema(query=Query)
- query{
- category(id: 1){
- id
- }
- }
- {
- "errors": [
- {
- "locations": [
- {
- "line": 2,
- "column": 3
- }
- ],
- "message": "resolve_category() takes 2 positional arguments but 4 were given"
- }
- ],
- "data": {
- "category": null
- }
- }
Add Comment
Please, Sign In to add comment