-
Notifications
You must be signed in to change notification settings - Fork 12
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
How deal with complex queries? #52
Comments
I think you're running into the auto-filtering logic of Mirage GraphQL (see #34). In this case, you'll want to add a custom resolver. Something like this: // app/mirage/server.js
import { createServer } from "miragejs"
import { createGraphQLHandler } from "@miragejs/graphql"
import graphQLSchema from "app/gql/schema.gql"
export function makeServer() {
return createServer({
routes() {
const graphQLHandler = createGraphQLHandler(graphQLSchema, this.schema, {
resolvers: {
Query: {
currentAccount(_obj, args, context) {
let currentAccount; // Fetch current account from the Mirage DB or build it up however you need
let membership = context.mirageSchema.memberships.find(args.membershipId);
let membershipVariant = context.mirageSchema.membershipVariants.find(args.variantId);
return {
...currentAccount,
memberships: [{
...membership,
membershipVariants: [{
...membershipVariant
}],
}],
};
}
}
}
});
this.post("/graphql", graphQLHandler)
}
})
} Apologies for any typos or incorrect method invocations from Mirage's API. IDK how you want to fetch or create the LMK if this helps for now. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Hey @sebamza17, since this new issue isn't directly related to the original, shall we discuss elsewhere? The Mirage Discord works well for me or you can open another GH issue. |
I'm getting a bunch of errors when I try to use queries with variables.
// schema
// query
Could you please give some help here @jneurock I might be missing something?
The text was updated successfully, but these errors were encountered: