Prisma 1 Forum

Feedback: Schema Extensions Beta

Schema Extensions is a new function type and a powerful addition that provides you the ability to extend your GraphQL API with a custom mutation or query.

To kickstart this beta program, we prepared two examples for custom authentication using Facebook Authentication or Google Authentication.

More examples have been contributed by the community:

Schema Extensions can be used for many more use cases, such as wrapping existing APIs or wrapping your own Graphcool API.

Please discuss questions or suggestions for this beta feature here. If you’re interested in contributing a new example or testing out an existing example, please send me a PM here :slightly_smiling_face:


Really liking this feature ! It’s awesome for wrapping API’s and keeping a lot of the logic for my front end applications in Apollo/Lokka.

One suggestion would be to improve the error handling ! I usually only get an “Internal Server Error” message, and this makes things difficult to debug. Thankfully there’s Nilan, but some basic error messages would be very helpful! Thanks !

Thanks a lot for your feedback, Patrick! I know you encountered this error where badly shaped return data is not handled gracefully.

Did you encounter different kinds of errors as well? Here’s the list of known issues.

We’ll fix these issues before releasing schema extension to every Graphcool user.

Hey Nilan, I also experienced this issue, where my input was getting wrapped in a Some()

1 Like

Our Use Case:

We use to spec out the contract between our frontend and backend teams. The frontend team then uses as a mock to develop against and the backend team uses it as a source of truth for what the endpoint should behave like. This is currently great for Types but, the auto generated queries and mutations are different from what we will “officially” support on the backend. It would be nice to be able to also write that spec in

Hi, I would love to try out the Beta

Our Use Case:

In our case the application is multi tenant and a user may belong to multiple organizations with different roles. I want to be able to manage this in auth0 and access the values to enforce access rules in Specifically I want to access app_metadata and user_metadata set in auth0 against the user. If its also possible to update these it would be great.

Hi Infra - That’s a super interesting use case. Could you provide some examples of the types of queries you need to support?

Do you use Graphcool simply as a schema generator or do you also use the functionality of storing and querying data during development?

Hi Luke

One way to go about this would be to treat Auth0 as the source of truth, and then keep a mirror in Graphcool. You could create a Serverside Subscription for Create User that looks up the data in Auth0 and stores it in Graphcool.

would that work for you?

Hi Sorenbs,

Mostly we just need CRUD queries but, it would be nice to say, “we’re only going to support a given sub set of types at the top level or for allNoun (where Noun is a given Type) you can pass a certain subset of fields as arguments for filtering.”

Also, and I haven’t tried to do this yet, CRUD collections that have different input and output types. Take an Image type for example it may take some fields like Id, Width, Height on Create but on Read returns a Src attribute with a computed URL.

We just started using it so the FE team does add mock data to but we don’t really expect it to be super robust.

Does that make sense?

1 Like

Hey guys,

Just noticed today that schema extension SDL for lists may not be working properly.


redacted: [String!]!


Argument 'redacted' expected type 'String!'

Thanks for reporting this Jimmy, this is being discussed in here :slightly_smiling_face:

You bring up an interesting point. Currently, the input and output schemas mirror each other. There’s already a fefature request for controlling them separately and I’d be interested to hear your thoughts on that one :slightly_smiling_face:

I think I’m missing something very obvious trying out the schema extension here: I followed the instructions. when I do a “Test Run” all looks good, but when I try to use it from the main “Playground” it fails.

Here’s my mutation in the playground:

  signupEmailUser(email:"", password:"test1234") {

And here’s the error:

  "data": {
    "signupEmailUser": null
  "errors": [
      "locations": [
          "line": 2,
          "column": 3
      "functionError": "Error: Unknown argument 'email' on field 'User' of type 'Query'. (line 3, column 12):\n      User(email: \"\") {\n           ^: {\"response\":{\"data\":null,\"errors\":[{\"message\":\"Unknown argument 'email' on field 'User' of type 'Query'. (line 3, column 12):\\n      User(email: \\\"\\\") {\\n           ^\",\"locations\":[{\"line\":3,\"column\":12}]}],\"status\":200},\"request\":{\"query\":\"\\n    query {\\n      User(email: \\\"\\\") {\\n        id\\n      }\\n    }\"}}",
      "path": [
      "code": 5001,
      "message": "function execution error: Error: Unknown argument 'email' on field 'User' of type 'Query'. (line 3, column 12):\n      User(email: \"\") {\n           ^: {\"response\":{\"data\":null,\"errors\":[{\"message\":\"Unknown argument 'email' on field 'User' of type 'Query'. (line 3, column 12):\\n      User(email: \\\"\\\") {\\n           ^\",\"locations\":[{\"line\":3,\"column\":12}]}],\"status\":200},\"request\":{\"query\":\"\\n    query {\\n      User(email: \\\"\\\") {\\n        id\\n      }\\n    }\"}}",
      "requestId": "simple:cj5y0djgn4hrm01472znstweu"

Thanks for your feedback @cball!

I am also puzzled why it works in Test Run :smiley: But it looks like the email field doesn’t have the @isUnique modifier. However, the query User(email: String) is only valid if the email field is marked unique.

So either you can mark the field unique, or use the appropriate allUsers query instead.

This looks to be a common pitfall of this example, so I just added a new section to the README for common error messages and how to fix them.

Thanks @nilan! Works like a champ. Read my mind on the README… I’d planned to do that once we figured it out. :slight_smile:

Email should absolutely be marked as @isUnique in this case.

1 Like

I’d love to let users authenticate to my app via Steam. They offer an OpenID provider (docs). Not sure if it’s possible to do that via Auth0. If not, it sounds like this is the only way.

1 Like

That’s a great use case, @wilson29thid. The existing authentication examples should give you a good place to start for the Steam integration, I’d be happy to review a PR for that as well :slight_smile:

Is there a size limit to the inline function feature?

I think we could use dependencies if we let webpack & babel make one big script.

Schema extensions would be highly beneficial to my current app. Recently I scrapped my node backend in favor of Graphcool. However, in doing so I lost the ability to grab a standard time from one place. My app deals with dates and I need the ability to pull the correct ranges that fall within the current date. Something like this:

filter: {
  AND: [{
    startDate_lte: CURRENT_DATE_HERE
  }, {
    endDate_gt: CURRENT_DATE_HERE

I cannot grab the date from the user’s client because that can be altered and therefore unacceptable. With schema extensions I am planning on injecting today’s date into the query.

1 Like

Hey Michael, that’s a great use case for schema extensions! You can refer to this example to query the Graphcool API in your function code.

Note that schema extensions are not automatically connected to permissions yet, so you need to do that in the code itself. Furthermore you can only return scalar fields in schema functions as of now, so you cannot just return a list of items. The current work around would be to return a JSON object with a list of JSON object.

Would love to see an example for this use case in the functions collection.