Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend graphql return mode to include the response when transport is http #921

Closed
jasonkuhrt opened this issue Jun 11, 2024 · 1 comment · Fixed by #991
Closed

Extend graphql return mode to include the response when transport is http #921

jasonkuhrt opened this issue Jun 11, 2024 · 1 comment · Fixed by #991

Comments

@jasonkuhrt
Copy link
Owner

Perceived Problem

Ideas / Proposed Solution(s)

This is the current Graffle return mode system:

Mode Throw Sources (no type safety) Returns (type safe)
graphql Extensions, Fetch GraphQLExecutionResult
graphqlSuccess Extensions, Fetch, GraphQLExecutionResult.errors GraphQLExecutionResult with .errors always missing.
data (default) Extensions, Fetch, GraphQLExecutionResult.errors GraphQLExecutionResult.data
dataSuccess Extensions, Fetch, GraphQLExecutionResult.errors, GraphQLExecutionResult.data Schema Errors GraphQLExecutionResult.data without any schema errors
dataAndErrors GraphQLExecutionResult.data, errors from: Extensions, Fetch, GraphQLExecutionResult.errors

I think it's fair to start with permitting response access in the low level escape hatch mode of graphql and graphqlSuccess. We can make the presence of response type safe based on client config (the transport).

We would be extending the native GraphQLExectionResult type so wherever that type is expected in the ecosystem the results of a raw Graffle request would still conform to the interface, the extra response field just being ignored.

I don't think the extensions field is the right place for this but I should double check actually, because I'm realizing now I'm not sure what the extensions field was really for.

@jasonkuhrt
Copy link
Owner Author

After some reflection I think the design of return mode needs to change into a more granular output settings:

Graffle.create({
  output: {
    response: true,
    extensions: true,
    throw: {
      schemaErrors: true,
      executionErrors: true,
      otherErrors: true,
    },
  },
})

We can still ship the currently defined return modes as pre-configured objects, sets of common patterns, for immediate use. Or perhaps the input type for this field accepts a union of either the object or an alias of a pre configuration. E.g.:

Graffle.create({
  output: 'graphql' | 'graphqlSuccess' | ...
})

jasonkuhrt added a commit that referenced this issue Jul 19, 2024
@jasonkuhrt jasonkuhrt unpinned this issue Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant