#javascript #amazon-web-services #graphql #aws-amplify
#javascript #amazon-веб-сервисы #graphql #aws-amplify
Вопрос:
У меня есть следующая схема
type League @model
@auth(rules: [{ allow: owner }]) {
id: ID!
name: String!
faId: ID!
logo: String
seasons: [Season] @connection(keyName: "bySeason", fields: ["id"])
division: [Division] @connection(keyName: "byDivision", fields: ["id"])
}
type Season @model @key(name: "bySeason", fields: ["leagueID"])
@auth(rules: [{ allow: owner }]) {
id: ID!
name: String!
faId: ID!
yearStart: AWSDate
yearEnd: AWSDate
leagueID: ID!
league: League! @connection(fields: ["leagueID"])
division: [Division] @connection(keyName: "byDivision", fields: ["id"])
}
type Division @model @key(name: "byDivision", fields: ["seasonID", "leagueID", "name"])
@auth(rules: [{ allow: owner }]) {
id: ID!
name: String!
faId: ID!
leagueID: ID!
seasonID: ID!
league: League! @connection(fields: ["leagueID"])
season: Season! @connection(fields: ["seasonID"])
}
Который отлично компилируется, затем я выполняю мутацию для создания лиги с:
Что приводит к приведенной ниже ошибке
mutation MyMutation($name: String!, $faId: ID!) {
createLeague(input: {name: $name, faId: $faId}) {
id
}
}
variables:
{
"name": "test 2",
"faId": "9031785"
}
Сообщение об ошибке
Error: Validation error of type UnknownType: Unknown type CreateLeagueInput
Validation error of type UnknownType: Unknown type ModelLeagueConditionInput
Validation error of type FieldUndefined: Field 'createLeague' in type 'Mutation' is undefined @ 'createLeague'
Эта же мутация работает с GraphiQL:
Я выполнил a codegen
и a gql-compile
Редактировать … с помощью определения docs.
Комментарии:
1. просто использовать «более короткую версию»? проверьте, показывает ли graphiql / docs тип мутации / ввода
2. Очень хороший момент xadm… Я пробовал это с мутацией:
export const CREATE_LEAGUE = gql mutation createLeague($name: String!, $faId: ID!) { createLeague(input: { name: $name, faId: $faId }) { id name faId logo } }
3. Что приводит к ошибке
Error: Validation error of type FieldUndefined: Field 'createLeague' in type 'Mutation' is undefined @ 'createLeague'
4. ‘проверьте, показывает ли graphiql / docs тип мутации / ввода’
5. Он указан в разделе
mutations
с типомLeague
, который я установил в схеме. Я добавил изображение к вопросу