graphql-tools
graphql-tools copied to clipboard
Add option to pluck raw GraphQL from custom Vue block
Is your feature request related to a problem? Please describe.
I'd like to pluck raw GraphQL from a custom Vue block:
<template>
<div>{{data.record}}</div>
</template>
<script setup lang="ts">
import { useGetRecordQuery } from '@/generated/graphql';
const { data } = useGetRecordQuery();
</script>
<graphql lang="gql">
query GetRecord {
record {
id
name
}
}
</graphql>
Describe the solution you'd like
Because the necessary work is already being done by the Vue parser, this feature adds useful functionality with minimal impact on the code. I have a branch ready to submit as a PR, I'm very open to suggestions regarding implementation and code style: https://github.com/jaschaephraim/graphql-tools/commit/c98d5c9f89925d361861a357a03c6d34a57bbbda?diff=split
It adds an option gqlVueBlock (defaults to undefined) to specify the name of a custom block you'd like plucked as raw GraphQL.
Describe alternatives you've considered
There's no other way I've found to do this using graphql-tag-pluck, and I'd ultimately like use this feature with graphql-code-generator.