Storybook does not resolve .graphql file imports
See original GitHub issueDescribe the bug
Storybook cannot import .graphql files. I’m trying to use graphql-tag/loader
, which I’m using in a react create project that uses typescript. It works fine in the app itself but when running storybook it does not resolve correctly.
To Reproduce Steps to reproduce the behavior:
- Create a storybook project
- Add graphql/tag to webpack config (info below)
- Include an import of a graphql file within your project/stories
- Start storybook
- Observe it does not import correctly
Expected behavior The import should resolve to a graphql object.
Actual behaviour The import resolves to the filename e.g. “static/media/create.d41dd6c7.graphql”
System:
System:
OS: macOS 10.15.1
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Binaries:
Node: 12.13.1 - /usr/local/bin/node
Yarn: 1.19.2 - /usr/local/bin/yarn
npm: 6.12.1 - /usr/local/bin/npm
Browsers:
Chrome: 79.0.3945.117
Safari: 13.0.3
npmPackages:
@storybook/addon-actions: 5.3.7 => 5.3.7
@storybook/addon-docs: 5.3.7 => 5.3.7
@storybook/addon-links: 5.3.7 => 5.3.7
@storybook/addon-storyshots: 5.3.7 => 5.3.7
@storybook/addon-viewport: ^5.3.1 => 5.3.7
@storybook/addons: 5.3.7 => 5.3.7
@storybook/preset-create-react-app: ^1.5.0 => 1.5.2
@storybook/react: 5.3.7 => 5.3.7
Additional context The following is added to the webpack.config.js rules of storybook:
{
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: "graphql-tag/loader",
}
the following added to the extensions:
config.resolve.extensions.push(".graphql")
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
How to import .graphql files with webpack - Stack Overflow
Easier to do: Instead of creating a graphql file you can just create a js file to save your queries and create them...
Read more >Modularizing your GraphQL schema code
js'; import { typeDef as Book, resolvers as bookResolvers, } from './book.js'; // If you had Query fields not associated with a //...
Read more >GraphQL Code Libraries, Tools and Services
A powerful JavaScript GraphQL client, designed to work well with React, ... No more render props hell; ⏳ Handle loading and error states...
Read more >typescript-resolvers - GraphQL Code Generator
Without loading your GraphQL operations ( query , mutation , subscription and fragment ), you won't see any change in the generated output....
Read more >GraphQL Modules tutorial: How to modularize GraphQL schema
GraphQL Modules is a set of libraries and guidelines designed to help you ... book.type.graphql import { gql } from 'graphql-modules'; ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ian-callaghan ran into the same problem. solved by adding to
main.js
:This works for me. From the Apollo graphQL docs: