Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(useStrapiGraphQL): support for imported graphql files #249

Merged
merged 7 commits into from
Jun 9, 2022
Merged

feat(useStrapiGraphQL): support for imported graphql files #249

merged 7 commits into from
Jun 9, 2022

Conversation

doseofted
Copy link
Contributor

@doseofted doseofted commented May 18, 2022

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

Adds support for queries that are imported from a file. For instance, if someone used @rollup/plugin-graphql with Vite to import a GraphQL file, the imported file would be a DocumentNode and not the expected query by the Nuxt/Strapi module today. This feature adds support for those imported queries directly in the module without the need to transform the query first, like so:

<script setup lang="ts">
import query from "~/queries/test.gql"

const given = await useStrapiGraphQL(query, { sort: ['createdAt:asc'] })
</script>

Since variables are defined on the query and can't be passed directly when using a file, an optional variables argument is added to the useStrapiGraphQL composable so that those arguments can be passed.

This change relies on #248 (a fix for missing header on request). It also adds a dependency of "graphql" for conversion of given graphql document.

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes (if not applicable, please state why)

@benjamincanac benjamincanac changed the title Support for imported graphql files feat(useStrapiGraphQL)!: support for imported graphql files May 25, 2022
@doseofted doseofted marked this pull request as ready for review May 27, 2022 15:35
@benjamincanac benjamincanac changed the title feat(useStrapiGraphQL)!: support for imported graphql files feat(useStrapiGraphQL): support for imported graphql files May 30, 2022
@benjamincanac benjamincanac merged commit 0dfee89 into nuxt-modules:dev Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants