Add instrument type query
This commit is contained in:
parent
66a0427183
commit
ac6c60f8c3
|
|
@ -23,6 +23,8 @@
|
|||
import Checkbox from '@/components/ui/Checkbox';
|
||||
import FilterGroup from '@/components/instruments/FilterGroup';
|
||||
|
||||
import INSTRUMENT_TYPES_QUERY from 'gql/queries/instrumentTypesQuery';
|
||||
|
||||
export default {
|
||||
|
||||
components: {
|
||||
|
|
@ -55,6 +57,12 @@
|
|||
};
|
||||
},
|
||||
|
||||
apollo: {
|
||||
instrumentTypes: {
|
||||
query: INSTRUMENT_TYPES_QUERY
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
change(enabled, index) {
|
||||
let type = this.types[index];
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
query InstrumentTypesQuery {
|
||||
instrumentTypes {
|
||||
name
|
||||
category
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
query InstrumentsQuery($type: String!){
|
||||
instruments(type: $type) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
title
|
||||
contents
|
||||
slug
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,5 +5,6 @@ query InstrumentsQuery {
|
|||
contents
|
||||
slug
|
||||
type
|
||||
category
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 2.2.24 on 2021-10-30 20:04
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('basicknowledge', '0009_auto_20211020_1213'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='basicknowledge',
|
||||
old_name='type',
|
||||
new_name='old_type',
|
||||
),
|
||||
]
|
||||
|
|
@ -6,12 +6,21 @@ from graphene_django.filter import DjangoFilterConnectionField
|
|||
from api.utils import get_object
|
||||
from notes.models import InstrumentBookmark
|
||||
from notes.schema import InstrumentBookmarkNode
|
||||
from .models import BasicKnowledge
|
||||
from .models import BasicKnowledge, InstrumentType
|
||||
|
||||
|
||||
class InstrumentTypeNode(DjangoObjectType):
|
||||
class Meta:
|
||||
model = InstrumentType
|
||||
only_fields = [
|
||||
'name', 'category'
|
||||
]
|
||||
|
||||
|
||||
class InstrumentNode(DjangoObjectType):
|
||||
bookmarks = graphene.List(InstrumentBookmarkNode)
|
||||
type = graphene.String()
|
||||
category = graphene.String()
|
||||
|
||||
class Meta:
|
||||
model = BasicKnowledge
|
||||
|
|
@ -25,6 +34,10 @@ class InstrumentNode(DjangoObjectType):
|
|||
def resolve_type(root: BasicKnowledge, info, **kwargs):
|
||||
return root.new_type.name
|
||||
|
||||
@staticmethod
|
||||
def resolve_category(root: BasicKnowledge, info, **kwargs):
|
||||
return root.new_type.category
|
||||
|
||||
def resolve_bookmarks(self, info, **kwargs):
|
||||
return InstrumentBookmark.objects.filter(
|
||||
user=info.context.user,
|
||||
|
|
@ -34,6 +47,7 @@ class InstrumentNode(DjangoObjectType):
|
|||
class InstrumentQuery(object):
|
||||
instrument = graphene.Field(InstrumentNode, slug=graphene.String(), id=graphene.ID())
|
||||
instruments = graphene.List(InstrumentNode)
|
||||
instrument_types = graphene.List(InstrumentTypeNode)
|
||||
|
||||
def resolve_instrument(self, info, **kwargs):
|
||||
slug = kwargs.get('slug')
|
||||
|
|
@ -47,3 +61,6 @@ class InstrumentQuery(object):
|
|||
|
||||
def resolve_instruments(self, info, **kwargs):
|
||||
return BasicKnowledge.objects.all().live()
|
||||
|
||||
def resolve_instrument_types(self, info, **kwargs):
|
||||
return InstrumentType.objects.all()
|
||||
|
|
|
|||
|
|
@ -206,12 +206,6 @@ type AssignmentNodeEdge {
|
|||
cursor: String!
|
||||
}
|
||||
|
||||
enum BasicKnowledgeType {
|
||||
LANGUAGE_COMMUNICATION
|
||||
SOCIETY
|
||||
INTERDISCIPLINARY
|
||||
}
|
||||
|
||||
type ChapterBookmarkNode implements Node {
|
||||
user: PrivateUserNode!
|
||||
note: NoteNode
|
||||
|
|
@ -462,6 +456,7 @@ type CustomQuery {
|
|||
projects: [ProjectNode]
|
||||
instrument(slug: String, id: ID): InstrumentNode
|
||||
instruments: [InstrumentNode]
|
||||
instrumentTypes: [InstrumentTypeNode]
|
||||
studentSubmission(id: ID!): StudentSubmissionNode
|
||||
assignment(id: ID!): AssignmentNode
|
||||
assignments(offset: Int, before: String, after: String, first: Int, last: Int): AssignmentNodeConnection
|
||||
|
|
@ -484,7 +479,7 @@ type CustomQuery {
|
|||
me: PrivateUserNode
|
||||
allUsers(offset: Int, before: String, after: String, first: Int, last: Int, username: String, email: String): PrivateUserNodeConnection
|
||||
myActivity(offset: Int, before: String, after: String, first: Int, last: Int, slug: String, slug_Icontains: String, slug_In: [String], title: String, title_Icontains: String, title_In: [String]): ModuleNodeConnection
|
||||
myInstrumentActivity(offset: Int, before: String, after: String, first: Int, last: Int, slug: String, type: String): InstrumentNodeConnection
|
||||
myInstrumentActivity(offset: Int, before: String, after: String, first: Int, last: Int, slug: String): InstrumentNodeConnection
|
||||
_debug: DjangoDebug
|
||||
}
|
||||
|
||||
|
|
@ -609,9 +604,10 @@ type InstrumentNode implements Node {
|
|||
slug: String!
|
||||
intro: String!
|
||||
contents: GenericStreamFieldType
|
||||
type: BasicKnowledgeType!
|
||||
id: ID!
|
||||
bookmarks: [InstrumentBookmarkNode]
|
||||
type: String
|
||||
category: String
|
||||
}
|
||||
|
||||
type InstrumentNodeConnection {
|
||||
|
|
@ -624,6 +620,17 @@ type InstrumentNodeEdge {
|
|||
cursor: String!
|
||||
}
|
||||
|
||||
enum InstrumentTypeCategory {
|
||||
LANGUAGE_COMMUNICATION
|
||||
SOCIETY
|
||||
INTERDISCIPLINARY
|
||||
}
|
||||
|
||||
type InstrumentTypeNode {
|
||||
name: String!
|
||||
category: InstrumentTypeCategory!
|
||||
}
|
||||
|
||||
scalar JSONString
|
||||
|
||||
input JoinClassInput {
|
||||
|
|
|
|||
Loading…
Reference in New Issue