Ошибки при запросе кеша клиента Apollo - PullRequest
0 голосов
/ 27 февраля 2020

После добавления данных коллекции в кэш я не могу получить один элемент из кэша с запросом.

//this query writes the data

const query = gql`
    query QQQ {
        users {
            __typename
            id
            something
        }
    }
`;

//this is the query I'm using to read the data

const query2 = gql`
    query QQQ2($id: ID!) {
        users(id: $id) @client {
            __typename
            id
            something
        }
    }
`;

//a collection of users is written to the cache

client.writeQuery({
    query: query,
    data: {
        users: [
            {
                __typename: 'User',
                id: 5,
                something: 'ABSDEF',
            },
            {
                __typename: 'User',
                id: 6,
                something: 'ABSDEFMM',
            },
        ],
    },
});


//this throws the error

const res = client.readQuery({
    query: query2,
    variables: { id: 5 },
});

Приведенный выше код приводит к следующей ошибке:

Ошибка в браузере

Это довольно простой c сценарий, но я не могу понять, что здесь происходит не так.

Спасибо

...