Prisma 1 Forum

Feedback: Schema Extensions Beta

Sounds interesting!

Our use case is simple, but the motivation is to get rid of Auth0.com for different reasons both in short and long-term, and use directly FB and Google social logins in our Expo.io app.

In short-term, we simply have a showstopper with Auth0. After “engaging” with Auth0 customer service now for a week, have to start look for other options…

In long-run, I’d rather manage one user DB, instead of having two in both Auth0 user list and in Graphcool User type. Also Auth0 user management tools look nice, but don’t really match our long-term needs.

2 Likes

Here’s an amazing example use case for wrapping an external REST API using Schema Extensions. In this case, it’s the Open Weather Map API: https://github.com/graphcool-examples/functions/tree/master/directions-and-geocoding/openweathermap-api

Thanks a lot for all your feedback! We’ve been able to fix some issues with SE functions as mentioned in the latest changelog

https://www.graph.cool/docs/faq/graphcool-changelog-chiooo0ahn/#week-3031-(july-24-august-8)

Hi, I would like to try the schema extension beta for some small app that I’m building, mostly to try to reuse most data in a modular way : the schema I have in mind could benefit a lot from extend type, and even interface inheritance if ever it is something that you plan to support eventually.

A side implementation I had in mind was to use GraphCool Function and Google authentication, Facebook authentication (or any third-party one) to authenticate users and automatically store basic informations in GraphCool about the user on a successful authentication (login, origin and token)

1 Like

Hello,

Would love to beta test Schema extensions, it would be useful to create a custom auth flow with email and pass, also to create some custom mutations instead of just using the CRUD operations.
Thanks :v:

1 Like

Some initial feedback from my initial fiddling with this.

  1. I could not find any mention how are dependencies handled. At some point, I even run into errors like Cannot find module 'graphcool-lib for some reason so I got the impression that it needs to be setup somewhere.

  2. When using graphcool-lib/fromEvent it does not work on Test Run because those fake data are missing projectId. Also test run event object should be as close as possible to real one, including arguments to query/mutation that’s being made.

  3. Forgetting to wrap return value of the function in data property ends with internal server error. Could be handled more gracefully.

  4. Returning data property which isn’t object yields error The return value should include a 'data' field of type object which is correct, but for some reason this failed call is not shown in log of the function so it’s harder to find out what went there.

  5. It would be really great if graphcool CLI could pull/push these functions as well instead of being forced manually put the code in console which is rather painful…

  6. Explain more what 'use latest' means. What functions are available? Is there some Babel preset behind it? For example ESM (import/export) does not seem to be working. This is important so development environment can be setup properly.

  7. When updating function with a parse error, it ends with endless spinner. Looking into dev console I see request failing there. Strangely enough Test Run seems to be executed against previous version of code that did not fail, so it’s impossible to find out the culprit. Try saving something simple as this which is obviously nonsense, but shows the problem nicely.

const Graphcool, { fromEvent } = require('graphcool-lib')

POST https://d0b5iw4041.execute-api.eu-west-1.amazonaws.com/prod/create/ 502 ()

Fetch API cannot load https://d0b5iw4041.execute-api.eu-west-1.amazonaws.com/prod/create/. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘https://console.graph.cool’ is therefore not allowed access. The response had HTTP status code 502. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.

It’s pretty much unusable without proper error reporting why the function cannot be updated

1 Like

Thanks so much for your thorough feedback, Daniel :pray:

  1. This is mostly covered by the function examples, did you have a look there how it’s done? Please provide instructions to reproduce this error message in our API bug tracker if you think this is a bug :slightly_smiling_face:
  2. Again, this is great feedback! There are already a lot of problems with Test Run documented here, and we’re planning to fix most of them before releasing schema extensions to the public. Again, if you think one problem you’re facing is not yet cover there, please create a new report.
  3. Totally agreed.
  4. Oh okay, I’ll try to reproduce that soon.
  5. :100: Absolutely! That’s a common feature request, and actually quite high on our priority list right now. We’ll soon be ready to roll out a separate beta for the new CLI version, so stay tuned for news :wink:
  6. This behaves the same as 'use latest' in webtask, and it gives you access to ES6 syntax. You can only export one function in the module right now, and import is not supported, that’s correct. Please submit a feature request with the behaviour you have in mind here.
  7. I already saw the issue you created on GitHub, thanks :raised_hands:

Again, your feedback is tremendously helpful and we’ll make sure to improve the experience when working with Schema Extensions :+1:

Hi, I’d love to try the Schema Extensions beta programme as well. For my application, Google Auth is the only service needed and the idea of storing user info in two places, Auth0 and Graph.cool just seems redundant. Can’t wait to try out the Google Authentication example.

When’s the planned date for the Schema Extensions to leave beta? and will everything be kept as usual when it does? Thanks

2 Likes

Sounds super cool, I’ll reach out in a PM :slightly_smiling_face:

There is no fix date yet. It shouldn’t be long anymore :wink:

I am not sure what you mean with that part, can you elaborate?

1 Like

Hi, I’d love to try the Schema Extensions beta program. We are going serverless and decided to use AWS Cognito as identity broker with Facebook and Google as IDPs. Our data primarily resides on graphcool and we don’t want to make it redundant on aws. Would like to give schema extensions a try.

That’s awesome! I’d love to see an AWS Cognito example in the functions collection, too :slight_smile: The other OAuth examples should give you a good starting point. Will reach out separately!

1 Like

Hi! We’d like to add Facebook/google auth and password reset flow to out application. @nilan, could you enable this feature for our project, please?

1 Like

I get your idea, but could you clear my mind and recommend some strategy about how can we achieve/implement multi tenant ?!

if I have to use functions, as I see, it will be necessary to create dozen of functions subscriptions to change my data before persist it, resulting in tree of them for each Type (Create, Update, Delete)… and how about when query data, Should we use permissions, is it possible, do you have any recomendation ?!

I would highly recommend that you use permission queries to govern multi-tenancy rules. With permission queries you can use relations to separate tenants.

I don’t fully understand your point about needing multiple functions for each type. Can you elaborate a little bit?

I reached out in a PM :slightly_smiling_face:

Never mind, as I was thinking about use “Request Pipeline” functions to do that. So in this type of function I have to choose the “hook” (created, updated, deleted) because of this I was saying it.

I belive will be very appreciated by the community an example about how to deal with multi tenant in graphcool. I mean… 2 different users saving data to same type but every user being able to query only your own data without provide any extra parameter to the query.

Hey @HerbertPimentel, this is a separate discussion to Schema Extensions, so could you please open a new thread for this? :slightly_smiling_face:

1 Like

Hello! I am interested in participating in this beta feature too, I am transferring old accounts that already have a password and I want to be transparent for our users. :slight_smile:

1 Like

@nilan
I’ve found a couple issues regarding Schema Extensions

First issue

  1. if the ‘Email-password auth’ integration is enabled - the ‘authProvider’ is required for ‘createUser’ mutation.
    And it means that next mutation is not valid
mutation {
        createUser(
          accountKitUserId:"${accountKitUser.id}"
        ){
          id
        }
      }

(this code taken from function examples)

I have to make is as follows:

mutation {
        createUser(
          accountKitUserId:"${accountKitUser.id}"
          authProvider: {
            email: {
              email: "none",
              password: "none"
            }}
        ){
          id
        }
      }

I guess ‘authProvider’ must not be a required filed.

Second issue
2. If Schema code is pasted as an endpoint to the AWS lambda function (not inline) - graphcool-lib is trying to read a ‘projectId’ from event.context.graphcool (see source code). Then it throws an error since event.context is undefined.
Here is a correct way to extract projectId:

projectId = JSON.parse(event.body).context.graphcool.projectId

It means that graphcool-lib is not usable in case when function is deployed to aws.