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

Only expose certian Queries/Mutations #1106

Open
Borduhh opened this issue May 25, 2022 · 6 comments
Open

Only expose certian Queries/Mutations #1106

Borduhh opened this issue May 25, 2022 · 6 comments

Comments

@Borduhh
Copy link

Borduhh commented May 25, 2022

We are contemplating using SOFA to generate an external REST API from our federated GraphQL API, but we want to be able to choose which queries/mutations we expose via the REST API. Is that possible with SOFA?

@Borduhh Borduhh changed the title Ignore Queries/Mutations Only expose certian Queries/Mutations May 25, 2022
@currentoor
Copy link

Ditto

@theguild-bot theguild-bot mentioned this issue Apr 24, 2023
22 tasks
@vincent-lecrubier-skydio

That seems crucial for any serious production use yes.

Is there a way today to achieve something similar maybe by transforming the schema before feeding it to SOFA?

@simoneromano96
Copy link

We're currently doing this with graphql-tools as such:

import { FilterRootFields, PruneSchema, schemaFromExecutor, wrapSchema } from "@graphql-tools/wrap"

const operationWhitelist = [
  "someoperation",
]

const schema = wrapSchema({
  schema: await schemaFromExecutor(executor),
  executor,
  transforms: [new FilterRootFields((_operationName, fieldName) => operationWhitelist.includes(fieldName)), new PruneSchema()],
})

@yuraxdrumz
Copy link

To those who try to do this with Apollo federation, I managed to get this to work.

import { FilterRootFields, PruneSchema, wrapSchema } from '@graphql-tools/wrap';  

  const operationWhitelist = ['createUser', 'updateUser', 'user', 'users'];
  const wrappedSchema = wrapSchema({
    schema: schema,
    transforms: [
      new FilterRootFields((_operationName, fieldName) => {
        return operationWhitelist.includes(fieldName);
      }),
      new PruneSchema(),
    ],
  });

Then you pass the wrapped schema to Apollo server as usual

@itpropro
Copy link

itpropro commented Apr 11, 2024

We also evaluated using Sofa for a public facing API, but this issue and #776 are pretty essential for that. Is this planned for the near future @ardatan or @Urigo ?

@Urigo
Copy link
Owner

Urigo commented Apr 17, 2024

Thanks everyone for commenting here
We are aiming to tackle this soon
Is anyone in this thread willing to go on a call with us, walk us through your current setup and your needs, get a shared Slack channel going with The Guild and test the new versions with us till we get it right?
If yes, simply email me (my email is on my GitHub profile)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants