Revert last few commits, as they changed too much for a hotfix

Revert "Fix readonly banner by making the me-query better cacheable"

This reverts commit 2de9fdcf12.
This commit is contained in:
Ramon Wenger 2024-03-28 16:16:08 +01:00
parent 2ea76918eb
commit 1594bb2b68
3 changed files with 50 additions and 40 deletions

View File

@ -18,7 +18,7 @@ const documents = {
"\n fragment ContentBlockHighlightsFragment on ContentBlockNode {\n id\n __typename\n highlights {\n ...HighlightParts\n }\n }\n": types.ContentBlockHighlightsFragmentFragmentDoc, "\n fragment ContentBlockHighlightsFragment on ContentBlockNode {\n id\n __typename\n highlights {\n ...HighlightParts\n }\n }\n": types.ContentBlockHighlightsFragmentFragmentDoc,
"\n query LanguageQuery {\n me {\n language @client\n }\n }\n ": types.LanguageQueryDocument, "\n query LanguageQuery {\n me {\n language @client\n }\n }\n ": types.LanguageQueryDocument,
"\n mutation SetLanguage($language: String!) {\n setLanguage(language: $language) @client {\n language\n }\n }\n ": types.SetLanguageDocument, "\n mutation SetLanguage($language: String!) {\n setLanguage(language: $language) @client {\n language\n }\n }\n ": types.SetLanguageDocument,
"\n query ReadOnlyQuery {\n me {\n readOnly\n selectedClass {\n readOnly\n }\n }\n }\n": types.ReadOnlyQueryDocument, "\n query ReadOnlyQuery {\n me {\n readOnly\n selectedClass {\n readOnly\n }\n }\n }\n ": types.ReadOnlyQueryDocument,
"\n fragment SubmissionParts on StudentSubmissionNode {\n id\n text\n final\n document\n submissionFeedback {\n id\n text\n teacher {\n firstName\n lastName\n }\n }\n }\n": types.SubmissionPartsFragmentDoc, "\n fragment SubmissionParts on StudentSubmissionNode {\n id\n text\n final\n document\n submissionFeedback {\n id\n text\n teacher {\n firstName\n lastName\n }\n }\n }\n": types.SubmissionPartsFragmentDoc,
"\n fragment AssignmentParts on AssignmentNode {\n id\n title\n assignment\n solution\n submission {\n ...SubmissionParts\n }\n }\n": types.AssignmentPartsFragmentDoc, "\n fragment AssignmentParts on AssignmentNode {\n id\n title\n assignment\n solution\n submission {\n ...SubmissionParts\n }\n }\n": types.AssignmentPartsFragmentDoc,
"\n query AssignmentQuery($id: ID!) {\n assignment(id: $id) {\n ...AssignmentParts\n }\n }\n ": types.AssignmentQueryDocument, "\n query AssignmentQuery($id: ID!) {\n assignment(id: $id) {\n ...AssignmentParts\n }\n }\n ": types.AssignmentQueryDocument,
@ -97,7 +97,7 @@ export function graphql(source: "\n mutation SetLanguage($language: String!)
/** /**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/ */
export function graphql(source: "\n query ReadOnlyQuery {\n me {\n readOnly\n selectedClass {\n readOnly\n }\n }\n }\n"): (typeof documents)["\n query ReadOnlyQuery {\n me {\n readOnly\n selectedClass {\n readOnly\n }\n }\n }\n"]; export function graphql(source: "\n query ReadOnlyQuery {\n me {\n readOnly\n selectedClass {\n readOnly\n }\n }\n }\n "): (typeof documents)["\n query ReadOnlyQuery {\n me {\n readOnly\n selectedClass {\n readOnly\n }\n }\n }\n "];
/** /**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/ */

View File

@ -26,49 +26,60 @@
</div> </div>
</template> </template>
<script setup lang="ts"> <script>
import { graphql } from '@/__generated__'; import gql from 'graphql-tag';
import { LICENSE_ACTIVATION } from '@/router/auth.names'; import { LICENSE_ACTIVATION } from '@/router/auth.names';
import { useQuery } from '@vue/apollo-composable';
import { computed } from 'vue';
const query = graphql(` export default {
query ReadOnlyQuery { data() {
me { return {
readOnly me: {
selectedClass {
readOnly
}
}
}
`);
const { result } = useQuery(query, null, {
fetchPolicy: 'cache-only',
});
const me = computed(() => {
const me = result.value?.me;
return (
me || {
readOnly: false,
selectedClass: {
readOnly: false, readOnly: false,
selectedClass: {
readOnly: false,
},
}, },
} licenseActivationLink: {
); name: LICENSE_ACTIVATION,
}); },
};
},
const isReadOnly = computed(() => { apollo: {
return me.value.readOnly || me.value.selectedClass?.readOnly; me: {
}); query: gql`
query ReadOnlyQuery {
me {
readOnly
selectedClass {
readOnly
}
}
}
`,
fetchPolicy: 'cache-only',
update({ me }) {
if (!me) {
return {
readOnly: false,
selectedClass: {
readOnly: false,
},
};
}
return me;
},
},
},
const readOnlyText = computed(() => { computed: {
return me.value.readOnly ? 'Sie besitzen keine aktive Lizenz.' : 'Sie sind in dieser Klasse nicht mehr aktiv.'; readOnlyText() {
}); return this.me.readOnly ? 'Sie besitzen keine aktive Lizenz.' : 'Sie sind in dieser Klasse nicht mehr aktiv.';
},
const licenseActivationLink = { isReadOnly() {
name: LICENSE_ACTIVATION, return this.me.readOnly || this.me.selectedClass?.readOnly;
},
},
}; };
</script> </script>

View File

@ -61,7 +61,6 @@ const typePolicies = {
keyFields: ['slug'], keyFields: ['slug'],
}, },
PrivateUserNode: { PrivateUserNode: {
keyFields: [], // i should never see anyone else's PrivateUserNode, so this should be a singleton
fields: { fields: {
language: { language: {
read() { read() {