Update and add to GraphQL typing in client and on server
This commit is contained in:
parent
4daf2946d2
commit
1927036610
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { ContentBlockNode } from '@/__generated__/graphql';
|
||||||
|
|
||||||
export type numberOrUndefined = number | undefined;
|
export type numberOrUndefined = number | undefined;
|
||||||
|
|
||||||
type types = 'task' | 'normal' | 'base_communication' | 'base_society' | 'base_interdisciplinary' | 'instrument';
|
type types = 'task' | 'normal' | 'base_communication' | 'base_society' | 'base_interdisciplinary' | 'instrument';
|
||||||
|
|
@ -17,8 +19,8 @@ export interface InstrumentCategory {
|
||||||
|
|
||||||
export interface Hideable {
|
export interface Hideable {
|
||||||
userCreated: boolean;
|
userCreated: boolean;
|
||||||
hiddenFor: any[];
|
// hiddenFor: any[];
|
||||||
visibleFor: any[];
|
// visibleFor: any[];
|
||||||
titleHiddenFor: any[];
|
titleHiddenFor: any[];
|
||||||
descriptionHiddenFor: any[];
|
descriptionHiddenFor: any[];
|
||||||
hidden: boolean;
|
hidden: boolean;
|
||||||
|
|
@ -30,12 +32,17 @@ export interface ContentBlock extends Hideable, Page {
|
||||||
type: types;
|
type: types;
|
||||||
notes: any[];
|
notes: any[];
|
||||||
bookmarks: any[];
|
bookmarks: any[];
|
||||||
indent?: boolean;
|
|
||||||
instrumentCategory: InstrumentCategory;
|
instrumentCategory: InstrumentCategory;
|
||||||
mine: boolean;
|
mine: boolean;
|
||||||
root: string;
|
root: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ExtendedContentBlockNode extends ContentBlockNode {
|
||||||
|
indent?: boolean;
|
||||||
|
notes: any[];
|
||||||
|
root: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface Chapter extends Hideable, Page {
|
export interface Chapter extends Hideable, Page {
|
||||||
contentBlocks: ContentBlock[];
|
contentBlocks: ContentBlock[];
|
||||||
bookmark: any;
|
bookmark: any;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -119,19 +119,17 @@ import DUPLICATE_CONTENT_BLOCK_MUTATION from '@/graphql/gql/mutations/duplicateC
|
||||||
import CHAPTER_QUERY from '@/graphql/gql/queries/chapterQuery.gql';
|
import CHAPTER_QUERY from '@/graphql/gql/queries/chapterQuery.gql';
|
||||||
import DELETE_CONTENT_BLOCK_MUTATION from '@/graphql/gql/mutations/deleteContentBlock.gql';
|
import DELETE_CONTENT_BLOCK_MUTATION from '@/graphql/gql/mutations/deleteContentBlock.gql';
|
||||||
|
|
||||||
import type { ContentBlock } from '@/@types';
|
import type { ExtendedContentBlockNode } from '@/@types';
|
||||||
import type { Modal } from '@/plugins/modal.types';
|
import type { Modal } from '@/plugins/modal.types';
|
||||||
import { PAGE_LOAD_TIMEOUT } from '@/consts/navigation.consts';
|
import { PAGE_LOAD_TIMEOUT } from '@/consts/navigation.consts';
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
contentBlock: ContentBlock;
|
contentBlock: ExtendedContentBlockNode;
|
||||||
parent?: any;
|
parent?: any;
|
||||||
editMode?: boolean;
|
editMode?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ContentComponent = defineAsyncComponent(
|
const ContentComponent = defineAsyncComponent(() => import('@/components/content-blocks/ContentComponent.vue'));
|
||||||
() => import(/* webpackChunkName: "content-components" */ '@/components/content-blocks/ContentComponent.vue')
|
|
||||||
);
|
|
||||||
|
|
||||||
const { me, schoolClass } = getMe();
|
const { me, schoolClass } = getMe();
|
||||||
|
|
||||||
|
|
@ -167,7 +165,9 @@ const { mutate: duplicateContentBlock } = useMutation(DUPLICATE_CONTENT_BLOCK_MU
|
||||||
id,
|
id,
|
||||||
};
|
};
|
||||||
const { chapter }: any = store.readQuery({ query, variables });
|
const { chapter }: any = store.readQuery({ query, variables });
|
||||||
const index = chapter.contentBlocks.findIndex((contentBlock: ContentBlock) => contentBlock.id === contentBlockId);
|
const index = chapter.contentBlocks.findIndex(
|
||||||
|
(contentBlock: ExtendedContentBlockNode) => contentBlock.id === contentBlockId
|
||||||
|
);
|
||||||
const contentBlocks = insertAtIndex(chapter.contentBlocks, index, contentBlock);
|
const contentBlocks = insertAtIndex(chapter.contentBlocks, index, contentBlock);
|
||||||
const data = {
|
const data = {
|
||||||
chapter: {
|
chapter: {
|
||||||
|
|
@ -201,7 +201,7 @@ const { mutate: doDeleteContentBlock } = useMutation(DELETE_CONTENT_BLOCK_MUTATI
|
||||||
};
|
};
|
||||||
const { chapter }: any = store.readQuery({ query, variables });
|
const { chapter }: any = store.readQuery({ query, variables });
|
||||||
const index = chapter.contentBlocks.findIndex(
|
const index = chapter.contentBlocks.findIndex(
|
||||||
(contentBlock: ContentBlock) => contentBlock.id === props.contentBlock.id
|
(contentBlock: ExtendedContentBlockNode) => contentBlock.id === props.contentBlock.id
|
||||||
);
|
);
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
throw Error('ContentBlock not found');
|
throw Error('ContentBlock not found');
|
||||||
|
|
|
||||||
|
|
@ -69,9 +69,9 @@ export const hidden: (options: {
|
||||||
userCreated: boolean;
|
userCreated: boolean;
|
||||||
visibleFor: any[];
|
visibleFor: any[];
|
||||||
hiddenFor: any[];
|
hiddenFor: any[];
|
||||||
titleHiddenFor: any[];
|
titleHiddenFor?: any[];
|
||||||
descriptionHiddenFor: any[];
|
descriptionHiddenFor?: any[];
|
||||||
hidden: boolean;
|
hidden?: boolean;
|
||||||
};
|
};
|
||||||
schoolClass: any;
|
schoolClass: any;
|
||||||
}) => boolean = ({
|
}) => boolean = ({
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ from api.graphene_wagtail import GenericStreamFieldType
|
||||||
class ContentBlockInterface(graphene.Interface):
|
class ContentBlockInterface(graphene.Interface):
|
||||||
title = graphene.String()
|
title = graphene.String()
|
||||||
contents = GenericStreamFieldType()
|
contents = GenericStreamFieldType()
|
||||||
type = graphene.String()
|
type = graphene.String(required=True)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def resolve_type(parent, info, **kwargs):
|
def resolve_type(parent, info, **kwargs):
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,89 @@ schema {
|
||||||
mutation: PublicMutation
|
mutation: PublicMutation
|
||||||
}
|
}
|
||||||
|
|
||||||
input BetaLoginInput {
|
type PublicQuery {
|
||||||
usernameInput: String
|
node(
|
||||||
passwordInput: String
|
"""The ID of the object"""
|
||||||
clientMutationId: String
|
id: ID!
|
||||||
|
): Node
|
||||||
|
_debug: DjangoDebug
|
||||||
|
}
|
||||||
|
|
||||||
|
"""An object with an ID"""
|
||||||
|
interface Node {
|
||||||
|
"""The ID of the object"""
|
||||||
|
id: ID!
|
||||||
|
}
|
||||||
|
|
||||||
|
"""Debugging information for the current query."""
|
||||||
|
type DjangoDebug {
|
||||||
|
"""Executed SQL queries for this API query."""
|
||||||
|
sql: [DjangoDebugSQL]
|
||||||
|
|
||||||
|
"""Raise exceptions for this API query."""
|
||||||
|
exceptions: [DjangoDebugException]
|
||||||
|
}
|
||||||
|
|
||||||
|
"""Represents a single database query made to a Django managed DB."""
|
||||||
|
type DjangoDebugSQL {
|
||||||
|
"""The type of database being used (e.g. postrgesql, mysql, sqlite)."""
|
||||||
|
vendor: String!
|
||||||
|
|
||||||
|
"""The Django database alias (e.g. 'default')."""
|
||||||
|
alias: String!
|
||||||
|
|
||||||
|
"""The actual SQL sent to this database."""
|
||||||
|
sql: String
|
||||||
|
|
||||||
|
"""Duration of this database query in seconds."""
|
||||||
|
duration: Float!
|
||||||
|
|
||||||
|
"""The raw SQL of this query, without params."""
|
||||||
|
rawSql: String!
|
||||||
|
|
||||||
|
"""JSON encoded database query parameters."""
|
||||||
|
params: String!
|
||||||
|
|
||||||
|
"""Start time of this database query."""
|
||||||
|
startTime: Float!
|
||||||
|
|
||||||
|
"""Stop time of this database query."""
|
||||||
|
stopTime: Float!
|
||||||
|
|
||||||
|
"""Whether this database query took more than 10 seconds."""
|
||||||
|
isSlow: Boolean!
|
||||||
|
|
||||||
|
"""Whether this database query was a SELECT."""
|
||||||
|
isSelect: Boolean!
|
||||||
|
|
||||||
|
"""Postgres transaction ID if available."""
|
||||||
|
transId: String
|
||||||
|
|
||||||
|
"""Postgres transaction status if available."""
|
||||||
|
transStatus: String
|
||||||
|
|
||||||
|
"""Postgres isolation level if available."""
|
||||||
|
isoLevel: String
|
||||||
|
|
||||||
|
"""Postgres connection encoding if available."""
|
||||||
|
encoding: String
|
||||||
|
}
|
||||||
|
|
||||||
|
"""Represents a single exception raised."""
|
||||||
|
type DjangoDebugException {
|
||||||
|
"""The class of the exception"""
|
||||||
|
excType: String!
|
||||||
|
|
||||||
|
"""The message of the exception"""
|
||||||
|
message: String!
|
||||||
|
|
||||||
|
"""The stack trace"""
|
||||||
|
stack: String!
|
||||||
|
}
|
||||||
|
|
||||||
|
type PublicMutation {
|
||||||
|
betaLogin(input: BetaLoginInput!): BetaLoginPayload
|
||||||
|
_debug: DjangoDebug
|
||||||
}
|
}
|
||||||
|
|
||||||
type BetaLoginPayload {
|
type BetaLoginPayload {
|
||||||
|
|
@ -15,37 +94,8 @@ type BetaLoginPayload {
|
||||||
clientMutationId: String
|
clientMutationId: String
|
||||||
}
|
}
|
||||||
|
|
||||||
type DjangoDebug {
|
input BetaLoginInput {
|
||||||
sql: [DjangoDebugSQL]
|
usernameInput: String
|
||||||
}
|
passwordInput: String
|
||||||
|
clientMutationId: String
|
||||||
type DjangoDebugSQL {
|
|
||||||
vendor: String!
|
|
||||||
alias: String!
|
|
||||||
sql: String
|
|
||||||
duration: Float!
|
|
||||||
rawSql: String!
|
|
||||||
params: String!
|
|
||||||
startTime: Float!
|
|
||||||
stopTime: Float!
|
|
||||||
isSlow: Boolean!
|
|
||||||
isSelect: Boolean!
|
|
||||||
transId: String
|
|
||||||
transStatus: String
|
|
||||||
isoLevel: String
|
|
||||||
encoding: String
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Node {
|
|
||||||
id: ID!
|
|
||||||
}
|
|
||||||
|
|
||||||
type PublicMutation {
|
|
||||||
betaLogin(input: BetaLoginInput!): BetaLoginPayload
|
|
||||||
_debug: DjangoDebug
|
|
||||||
}
|
|
||||||
|
|
||||||
type PublicQuery {
|
|
||||||
node(id: ID!): Node
|
|
||||||
_debug: DjangoDebug
|
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue