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

Apollo Server 2: Remove formatParams #1331

Merged
merged 5 commits into from
Jul 13, 2018
Merged

Conversation

evans
Copy link
Contributor

@evans evans commented Jul 11, 2018

This removes formatParams, because it is an internal implementation detail of the new Apollo Server as opposed to a first class functionality as in the middleware. It was originally used to implement a form of persisted queries, which is now unnecessary.

In the future, we are planning to move to a more extensible request pathway inside of Apollo Server that should provide the functionality that was originally provided by formatParams. If you are dependent on the behavior of formatParams, please open an issue and we can continue discussions there. In the meantime, the release candidate(rc.7) provides a stop-gap measure.

@@ -40,16 +40,12 @@ Apollo Server provides two ways to log a server: per input, response, and errors

### High Level Logging

To log the inputs, response, and request, Apollo Server provides three methods: `formatParams`, `formatError`, and `formatResponse`. This example uses `console.log` to record the information, servers can use other more sophisticated tools.
To log the inputs, response, and request, Apollo Server provides three methods: `formatError` and `formatResponse`. This example uses `console.log` to record the information, servers can use other more sophisticated tools.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer have three methods, and no way to log the inputs with a simple callback.

For most other functions that might have required access to the middleware arguments, such as `formatParams`, `formatError`, and `formatResponse`, it is possible to create a `graphql-extension`.

For more complicated use cases, the `ApolloServer` class can be extended to override the `createGraphQLServerOptions` function to create parameters based on the same argument that's passed to the context.

<h2 id="log-function">Replacing `logFunction`</h2>

Apollo Server 2 removes the `logFunction` in favor of using `graphql-extensions`, which provides a more structured and flexible way of instrumenting Apollo Server. The explanation of how to do this more granular logging, can be found in the [metrics section](./features/metrics.html)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably note that extensions are not a public API yet at this point.

@evans evans merged commit 990d915 into version-2 Jul 13, 2018
@evans evans deleted the server-2.0/remove-formatParams branch July 13, 2018 16:44
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants