Iam new to graphql.Iam implementing a react-native app using aws appsync.We are facing problem in implementing #isUnique and giving it is giving me an error
Failed to parse schema document - ensure it's a valid SDL-formatted document.
type Person {
id: ID! #isUnique
createdAt: String!
updateAt: String!
name: String!
messages: [Messages!]!
#relation(name: "UserMessages")}
I want to have a random id generated for each user in the schema.How can we achieve this.
Thanks in Advance!!
#isUnique is a provider-specific directive. If you want to generate unique identifiers on the server with AWS AppSync, you can use $util.autoId() in the resolver. The AWS AppSync - Up and Running blog post has details.
First, it's #unique if you're using appolo-server and #isUnique if graphcool. Second, ids will be unique by default there is no need for #unique. It's for other fields like email or username.
Take a look here Schema directives - Appolo
If you're using Graphcool this
Related
In my project, we plan to implement a progressive disclosure (displaying some part of UI data if the user has permissions). Basically, we are using react + apollo client with hooks + graphqltag.
But the problem is no that how to hide some part of UI but how to split queries by permissions. So right now for pages, we create a single query containing many "subqueries" for different kinds of data. For example :
export const GET_DATA_X= gql`
query getDataX(
$applicationId: ID!
$dateFrom: String!
$dateTo: String!
$displayMode: String!
) {
applicationShipDates(
applicationId: $applicationId
dateFrom: $dateFrom
dateTo: $dateTo
displayMode: $displayMode
) {
periodStartDate
dates
}
graphStatistics(
applicationId: $applicationId
dateFrom: $dateFrom
dateTo: $dateTo
) {
totalVisits
totalConversions
conversionRate
}
}
`;
And right now each part of this query will be available if the user will have permission. On the backend side, it's already handled. We throw null/empty array and error. But IMO we shouldn't even ask for this part of the data. And that is the question. Do you have any suggestions on how to do this with an apollo client?
Right now I have two ideas on how to do that:
Split queries into single and make a few API calls if the user has permission, otherwise skip it
Write a custom function where I will pass as a prop array of objects, including query definition and query required permissions. I will filter this array by permission and from small query definitions like applicationShipDates or graphStatistics i will create a big query like getDataX which will includes few "subqueries"
Like #xadm mentioned directives will be the best solution.
I'm building a project with React and Firebase. When my users register, the submit the following information:
email: ''
userId: ''
venueAddress: ''
venueName: ''
So far I can access the email and userId using const user = auth().currentUser.email, but I'd like to be able to extract the venueName property too - is this possible? Or can you only extract the email and password properties?
const user = auth().currentUser.email
Through this you are explicitly asking for email property of the currentUser object.
In order to access venueName property of the currentUser object use the following -
auth().currentUser.venueName
Also you can explore other properties as well of the object by using the following function -
auth().currentUser
Here is the firebase docs link you can look into for further info -
https://firebase.google.com/docs/auth/web/manage-users#get_a_users_profile
A Firebase Authentication user only contains the properties defined here: https://firebase.google.com/docs/reference/js/firebase.User. As you can see, these are only properties related to authentication itself.
A Firebase Authentication user does not include any application specific values, such as your venueName. If you want to track such values, you'll typically create a record for each user in your database that you associate with the user's UID.
I'm currently working on revising the registration procedure of our recruitment ATS, made with AngularJS and Meteor, and I need to verify the new user's email during the registration procedure.
The logic would go as followed:
1- User fills in a form on the 'get-started' page and when clicking on 'sumbit', the ATS sends a verification email(I'll be using 'sendVerificationEmail' from Meteor)
2- After the user clicks on the link from the email, they'll get redirected to the 'register' page where additional information is required and the registration procedure is concluded.
As mentioned above, I'm planning to use 'sendVerificationEmail' to verify the user but I also want to use it to send back the userID.
From what I read on the Meteor API, I can pass extra data to the token with 'extraTokenData'
Accounts.sendVerificationEmail(userId, [email], [extraTokenData])
Now how do I declare the 'extraTokenData' object?
Could I do it like this: Accounts.sendVerificationEmail(userId, "", { _id: userId })
And how do I retrieve the 'userId' with 'Accounts.onEmailVerificationLink'?
your help will be greatly appreciated.
The email and the extra tokens are optionals, but if you want to send them send it as a string.
If you want to send the extra token but no emails you can try using Accounts.sendVerificationEmail(userId, undefined, "extra token") or if it doesn't work you can request the user's deatil user Meteor.user(). then call user.emails[0].address.
To retrieve information you have to get user by token and all data are there on user document under services.password.reset field. Look here how Accounts.generateResetToken is implemented https://github.com/meteor/meteor/blob/1e7e56eec8414093cd0c1c70750b894069fc972a/packages/accounts-password/password_server.js#L609.
I think I'm close, but there's just something I'm missing:
GIVEN:
We just want to be able to open our app, get the UserID from salesforce (which would match the UserID in our app), and log us in ... seems easy enough.
We are trying to use the open source C# component AspNetSaml https://github.com/jitbit/AspNetSaml
I have a cloud instance that hosts our app, for testing:
The URL to get to our app would be something along the lines of: http://1.2.3.4/OurCompanyApp/app.wgx
SALESFORCE:
I didn't initiate this process, but I do see that in Salesforce we have it setup as an Identity Provider. So I see this information under Identity Provider:
Issuer: https://our-company-stuff.my.salesforce.com
Label: SelfSignedCert_04Nov2016_195856
Unique Name: SelfSignedCert_04Nov2017_195856
Key Size: 2048
Salesforce Identity: https://our-company-stuff.my.salesforce.com/.well-known/samlidp.xml
I did set up a Service Provider via Connected Apps:
Connected App Name: AppTest
API Name: AppTest
Description: AppTest
Start URL: http://1.2.3.4/OurCompanyApp/app.wgx
Enable SAML: true
Entity ID: http://1.2.3.4/OurCompanyApp/app.wgx
ACS URL: http://1.2.3.4/OurCompanyApp/samlconsume.wgx
Enable Single Logout: false
Subject Type: User ID
Name ID Format: urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified
IdP Certificate: Default IdP Certificate
ACTUAL CODE:
//var samlEndpoint = "https://csi1-dev-ed.my.salesforce.com/";
//var samlEndpoint = "https://csi1-dev-ed.my.salesforce.com/.well-known/samlidp.xml";
(one of these would be un-commented)
var request = new AuthRequest(
"http://1.2.3.4/OurCompanyApp/app.wgx", //put your app's "unique ID" here
"http://1.2.3.4/OurCompanyApp/samlconsume.wgx" //assertion Consumer Url - the URL where provider will redirect authenticated users BACK
);
string url = request.GetRedirectUrl(samlEndpoint);
Response.Redirect(url);
GetRedirectUrl encrypts this bit of xml:
xw.WriteStartElement("samlp", "AuthnRequest", "urn:oasis:names:tc:SAML:2.0:protocol");
xw.WriteAttributeString("ID", _id);
xw.WriteAttributeString("Version", "2.0");
xw.WriteAttributeString("IssueInstant", _issue_instant);
xw.WriteAttributeString("ProtocolBinding", "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST");
xw.WriteAttributeString("AssertionConsumerServiceURL", _assertionConsumerServiceUrl);
xw.WriteStartElement("saml", "Issuer", "urn:oasis:names:tc:SAML:2.0:assertion");
xw.WriteString(_issuer);
xw.WriteEndElement();
xw.WriteStartElement("samlp", "NameIDPolicy", "urn:oasis:names:tc:SAML:2.0:protocol");
xw.WriteAttributeString("Format", "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified");
xw.WriteAttributeString("AllowCreate", "true");
xw.WriteEndElement();
The URL Returned, that I redirect to, would be something along the lines of (depending upon which endpoint I tried, I tested with both):
https://our-company-stuff.my.salesforce.com/?SAMLRequest=jZJdT8IwGIX%2fStP77oMx2Bq2BCHGJagLTC%2b8Md1WpEnXzn5M%2ffeWgQleSLxr3pxznvO%2b6UKTjvd4ac1BbOm7pdqAYp3B11kwn8SzZI%2bSuG3RdEZSVLfzGjVJTAL3COuogeCZKs2kyODECyAotLa0ENoQYdwoCBMURCgIqzDF0wiH0QsEpZJGNpLfMNEy8ZZBqwSWRDONBemoxqbBu%2bX9BrtEXJ9EGt9VVYnKx10FwVJrqoyDrqTQtqNqR9XAGvq03WTwYEyPfT%2beemnghXHohak%2fMGUs4bJ2voEqv5TaeEfEOcAbZMch%2bOy40Hg8x%2fVS%2fXkDmC%2bOajxurS781%2b3kpz%2fM%2f9N2kGO%2fhX%2fBOoF7%2fODCi3UpOWu%2bwK1UHTF%2fs136OGEt2o9SbIXuacP2jLburJzLj5WixNAMGmUpBH5%2bov7%2bHvk3
RESULTS:
I've tweaked Identity ID's, endpoint's, configurations, but Salesforce never hits our samlconsume.wgx, and all the redirect does is take me to my homepage at: https://our-company-app.salesforce.com/home/home.jsp
I'm at a loss right now. Any help would be much appreciated.
Please can someone assist me. I am new to DocuSign. I have a project I am working on whereby the customer wants to be able to send multiple documents to a recipient for signature. From the standard DocuSign set up, you can add documents upon envelope creation but I am looking for a way to automate this. For instance I created a custom button that automatically sends the envelope to a recepient. But it seems I can only add one document template there. Could someone please advise me on what to actually do or where to look because I cant seem to find anything. I see some recipies on the DocuSign help but they are in python etc and I want instruction on Salesforce.
POST
https://demo.docusign.net/restapi/v2/accounts/[accountId]/envelopes
In your create envelope body, you can specify multiple documents like:
emailSubject: "subject",
recipients: {
signers: [{
recipientId: 1,
email: "signer#email.com",
name: "Signers name"
}]},
documents: [{
documentId: 1,
filePath: 'your/path/here/1',
},
{
documentId: 2,
filePath: 'your/path/here/2',
}],