Skip to content

How deal with complex queries?  #52

@villander

Description

@villander

I'm getting a bunch of errors when I try to use queries with variables.

image

// 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);

      this.post("/graphql", graphQLHandler)
    }
  })
}

// schema

import { gql } from 'glimmer-apollo'

export const graphQLSchema = gql`
  type CurrentAccount {
    id: ID!
    name: String!
    flags: [String]!
    memberships: [Membership]
  }

  type Account {
    id: ID!
    accountType: String!
    isActive: Boolean!
    name: String!
  }

  type CurrentUser {
    id: ID!
    name: String!
    email: String!
    imageUrl: String!
    phone: String!
    isPeekAdmin: Boolean!
    currentAccountRoles: [String]
    accounts: [Account]
  }

  type Membership {
    id: ID!
    name: String!
    membershipVariants: [MembershipVariant!]!
  }

  type MembershipVariant {
    colorHex: String!
    creditsPerTerm: Int!
    description: String!
    externalName: String!
    id: ID!
    imageUrl: String!
    internalName: String!
  }

  type Query {
    currentAccount: CurrentAccount!
    currentUser: CurrentUser!
    memberships(id: ID!): [Membership!]!
  }
 `

// query

query CurrentAccountMembershipVariant($membershipId: ID, $variantId: ID) {
  currentAccount {
    id
    memberships(id: $membershipId) {
      id
      membershipVariants(id: $variantId) {
        id
        internalName
        externalName
        description
        currency
        creditsPerTerm
        imageUrl
        colorHex
        validBetween
        validFor {
          amount
          unit
        }
        creditWindow {
          unit
          amount
        }
      }
    }
  }
}

Could you please give some help here @jneurock I might be missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions