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

Error when using template string where query/mutation directives are added #725

Open
dashmedialtd opened this issue Sep 20, 2024 · 0 comments

Comments

@dashmedialtd
Copy link

dashmedialtd commented Sep 20, 2024

Describe the bug
When I'm using a template string to add in locale directives to a query/mutation, it gives me an error of "'@' or '{' expected, got '$'".

// This example has the function type removed and a 
// string type added to the locale parameter, this is to 
// make it possible to paste into your IDE.
const POLICY_PAGE_QUERY = (locale: string) => `#graphql
	query PolicyPageQuery($handle: String!) ${locale} {
		policy: metaobject(handle: {
			handle: $handle,
			type: "policies"
		}) {
			title: field(key: "title") {
				value
			}
			content: field(key: "content") {
				value
			}
			updatedAt
		}
	}
`;

This causes other errors within the query as well, as gql variables are described as both unused and undefined.

To Reproduce
Paste the above into a typescript document within Webstorm with the plugin enabled. The error will appear.

Expected behavior
The IDE should ignore the existence of the template string.

Screenshots
Screenshot 2024-09-20 161355

Version and Environment Details
Operation system: Windows 11 64bit
IDE name and version: WebStorm 2024.2.2
Plugin version: 242.21829.3

Additional context
This is being used to add locale directives to Shopify Storefront API requests. I am currently on a trial of WebStorm and this is the only thing stopping me from swapping over from VS Code.

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

No branches or pull requests

1 participant