0

I have graphql schema which contains a couple of mutations and queries. I think validation of mutation should call only when I send mutation { ... } to graphql server but currently, the server says me that I did not send arguments for all declared mutations.

type User {
  id: ID!,
  username: String!
}

type Auth {
  username: String
  password: String
}

enum Kind {
  COMPANY
  PERSONAL
  FREELANCE
  OPEN_SOURCE
}

type Job {
  kind: Kind!
  name: String
  link: String
  github: String
  npm: String
  isTool: Boolean
  address: String
}

type Project {
  year: Int!
  description: [String]!
  job: Job
  name: String
  notImportant: Boolean
  prefix: String
  tags: [String]!
  teamSize: String
}

type Query {
  projects: [Project!]!
  me: User
}

type Mutation {
  login(authData: Auth): Boolean
  addProject(project: Project): ID!
}

schema {
  query: Query
  mutation: Mutation
}

And I create executable schema via graphql-tools:


export const graphqlSchema = makeExecutableSchema({
  typeDefs: `*here is that schema*`,
  resolvers: mergeResolvers([projectResolvers, authResolvers]) as any,
  resolverValidationOptions: {
    requireResolversForResolveType: false,
    requireResolversForArgs: false,
    requireResolversForAllFields: false,
  },
  allowUndefinedInResolve: true,
});

(makeExecutableSchema it is part of the exports of graphql-tools package)
(data in resolvers it is object which not contain Mutation)

When I launch express server with express-graphql and open graphiql and put query (not mutation) for getting my projects it says me: enter image description here

What's I do wrong? Hope for your help, thanks!

Sergey Volkov
  • 871
  • 11
  • 17

1 Answers1

0

Heh, I found an answer on my own question. GraphQl says me what I should fix in schema but I not understood him. Input types (args for mutations should be Input Type):

input MyInput {
  foo: String
}

...
type Mutation {
  getBar(foo: MyInput): String
}
Sergey Volkov
  • 871
  • 11
  • 17