HomeServicesOfAmerica / moleculer-graphql

[Archived] GraphQL Schema stitching over a microservice network for co-located type definitions.
GNU General Public License v3.0
48 stars 17 forks source link

Type "Mutation" was defined more than once. #6

Closed evseevnn-zz closed 6 years ago

evseevnn-zz commented 6 years ago

@brad-decker That happen when i trying start 2 services and every one has graphql schema. Can i do that or only one service can has it?

brad-decker commented 6 years ago

@evseevnn can you share your service schemas so I can check it out? You should be able to define as many as you want. If you can provide the use case that breaks it I can work on fixing!

evseevnn-zz commented 6 years ago

@brad-decker Thank! Sure! Im just trying use 2 empty schemas in defferent services

type Query {
    _id: ID!
}

type Mutation {
    _id: ID!
}

type Subscription {
    _id: ID
}

schema {
  query: Query
  mutation: Mutation
  subscription: Subscription
}
brad-decker commented 6 years ago

@evseevnn your Mutation type, and likely your query type as well are failing because they aren't being defined as an appropriate type. If you take a look at http://graphql.org/graphql-js/mutations-and-input-types/

Query and Mutation types should contain query definitions rather than field definitions.

Here's an example:

type Book {
  id: Int,
  title: String,
  authorId: Int,
  year: Int,
}

type Query {
  book(id: Int!): Book,
  books: [Book],
  booksByAuthor(authorId: Int!): [Book],
}

input UpdateBookInput {
  id: Int!
  clientMutationId: Int!
  title: String
}

type UpdateBookPayload {
  book: Book
  clientMutationId: Int
}

type Mutation {
  updateBook(input: UpdateBookInput!): UpdateBookPayload,
}

Full disclosure i tested your use case on a version based on my pr #8 - so if you update your schema and still run into problems a new version is on its way that will address the issue.

evseevnn-zz commented 6 years ago

@brad-decker Hi! I'm sorry that your time spent. No, trouble not in Mutation type, trouble in my code. Sorry again.