Я пытаюсь понять, как издеваться над запросами, когда клиент опережает сервер. Я хотел бы иметь возможность просто запрашивать литералы, чтобы я мог вернуться и изменить их позже, есть ли способ сделать что-то подобное?
query myQuery {
type {
fieldName: 42
}
}


Да, довольно легко настроить фиктивные ответы, если у вас настроен хотя бы шаблонный код сервера. Если вы используете Apollo, у вас есть встроенные инструменты для облегчения моков.
https://www.apollographql.com/docs/graphql-tools/mocking.html
Из документов:
The strongly-typed nature of a GraphQL API lends itself extremely well to mocking. This is an important part of a GraphQL-First development process, because it enables frontend developers to build out UI components and features without having to wait for a backend implementation.
Вот пример из документации:
import { makeExecutableSchema, addMockFunctionsToSchema } from 'graphql-tools';
import { graphql } from 'graphql';
// Fill this in with the schema string
const schemaString = `...`;
// Make a GraphQL schema with no resolvers
const schema = makeExecutableSchema({ typeDefs: schemaString });
// Add mocks, modifies schema in place
addMockFunctionsToSchema({ schema });
const query = `
query tasksForUser {
user(id: 6) { id, name }
}
`;
graphql(schema, query).then((result) => console.info('Got result', result));
This mocking logic simply looks at your schema and makes sure to return a string where your schema has a string, a number for a number, etc. So you can already get the right shape of result. But if you want to use the mocks to do sophisticated testing, you will likely want to customize them to your particular data model.