rollup / plugins

🍣 The one-stop shop for official Rollup plugins
MIT License
3.57k stars 568 forks source link

[@rollup/plugin-graphql] Processing GraphQL queries declared in template files #1687

Open lermontex opened 4 months ago

lermontex commented 4 months ago

Feature Use Case

I'm using Vue 3 + Apollo GraphQL (composition API). I don’t use additional files (.gql/.graphql) to store GraphQL queries, but write them directly in files with the .vue extension, here’s a simple example:

// ...
import { gql } from "@apollo/client/core";
// ...

    const {
      mutate: createInvoiceMutationMutate,
    } = useMutation(
      gql`
        mutation createInvoice($input: createInvoiceInput!) {
          createInvoice(input: $input) {
            clientMutationId
            invoice {
              id
            }
          }
        }
      `,
    );

Unfortunately, at the moment there is no way to handle such a GraphQL query using @rollup/plugin-graphql

Feature Proposal

It would be great to be able to handle GraphQL queries that are declared in template files if they are wrapped in gql literal

UPD: https://github.com/apollographql/graphql-tag