-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
sort documents and fragments #384
Comments
Hmm, so the issue happens on client-side documents, that you build using JavaScript variables? and then it uses fragments from another file? can you please give an example for this usage? |
While writing this I realized I can probably work around my specific issue with var hoisting, but I'll still provide the details as it might be an issue for languages where hoisting isn't allowed: I'm using the # src/event.gql
fragment eventFields on Event {
id
start
end
title
description
} # src/calendar.gql
#import "./event.gql"
fragment calendarEvents on Calendar {
events: eventsByParentCalendarId {
nodes {
...eventFields
}
}
} This will output a type file with |
You should use https://github.com/prismagraphql/graphql-import to use this syntax and import the file correctly. |
I'm not that familiar with the |
It's not official, it's still a spec proposal. What I don't like is the fact that people should be educated to use this library properly, and if they don't they will come here writing issues. I think this should stay at userspace while It wouldn't hurt to add a section to the Readme or create another file called "recipes" or something like this. import { importSchema } from "graphql-import";
export default importSchema("./src/schema.graphql"); and invoking
Who needs it could do it by themselves, imho. |
@degroote22 But, maybe that's exactly what we should implement here - provide a flag like |
What's the problem with the current approach of having the CLI look for the documents? |
@degroote22 in order to apply preprocessing, such as import resolution, like you did on the schema side. Something like import { resolveDocuments } from "graphql-document-import";
export default resolveDocuments("./src/queries.graphql"); |
Realized this can actually be solved by ordering the arguments to the generator. It would be nice to dedupe the expanded glob, because it seems |
Ran into an issue where
a-fragment.gql
depended onb-fragment.gql
, which throws an error when the generated output is actual code (i.e.const B = a.Fragment
, although interestingly only at runtime when namespaced). Although an ideal solution might be to add a flag for sorting based on #imports or something, it's probably more expedient to add something like afiles
option to the config that has some globbing syntax:The text was updated successfully, but these errors were encountered: