question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.graphql, .gql import error

See original GitHub issue

Environment


  • Operating System: Linux
  • Node Version: v14.18.1
  • Nuxt Version: 3.0.0-27245461.ffb05fc
  • Package Manager: Yarn
  • Bundler: Vite
  • User Config: ssr, buildModules, css, vite
  • Runtime Modules: -
  • Build Modules: nuxt-windicss@2.0.3

Describe the bug

Rollup does not support graphql files.

 ERROR  Rollup error: Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)  

Reproduction

Import graphql file like:

import Product from './graphs/product.graphql';

Additional context

No response

Logs

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:7
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
fanckushcommented, Nov 10, 2021

@ririen I got to work but with another plugin. Here’s how you can get it to work:

First, install the rollup graphql plugin:

yarn add -D @rollup/plugin-graphql
// nuxt.config.ts
import { defineNuxtConfig } from "nuxt3";
import graphql from '@rollup/plugin-graphql';

export default defineNuxtConfig({
  vite: {
    plugins: [graphql()],
  },
});
0reactions
danielroecommented, Mar 7, 2022

Closing as this isn’t a bug. Likely integrations with graphql will be implemented with nuxt modules.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to solve GraphQl ImportError - cannot import name 'gql ...
I tried using the Basic example available on Official Github Page. in my Python IDLE. However, I am getting this ImportError in my...
Read more >
Typescript: import fail: Cannot find module 'query.gql' #59
when you do: import schema from './schema.graphql'; , you import default property of the module, but exported doc doesn't have it, so it...
Read more >
Loading queries with Webpack - Apollo GraphQL Docs
You can load GraphQL queries over .graphql files using Webpack. ... As you can see, .graphql or .gql files will be parsed whenever...
Read more >
graphql-import-files - npm
Start using graphql-import-files in your project by running `npm i graphql-import-files`. There are no other projects in the npm registry ...
Read more >
The graphql module exports a core subset of GraphQL ...
import { graphql } from 'graphql'; // ES6. var { graphql } = require('graphql') ... Format an error according to the rules described...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found