This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func alfa(i int) (int, error) { | |
if i > 1 { | |
return i, nil | |
} | |
return 0, fmt.Errorf("i was greater than 1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mutation { | |
createProduct(data:{ | |
name: "Apple", | |
price: { | |
create: [ | |
{ | |
price: 1.20, | |
store: { | |
create: { | |
name: "Jumbo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
<div *ngFor="let product of products$ | async"> | |
Product: {{product.name}} | |
<div *ngFor="let price of product.price.data"> | |
Store: {{price?.store?.name}} Price: {{price?.price}} | |
</div> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
<div *ngFor="let product of products$ | async"> | |
{{product.name}} | |
<div *ngFor="let price of product.price.data"> | |
{{price.price}} | |
</div> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
import { ProductService } from 'src/app/services/data/product.service'; | |
import { Observable } from 'rxjs'; | |
import { Products_allProducts_data } from 'src/app/services/data/__generated__/Products'; | |
@Component({ | |
selector: 'app-list', | |
templateUrl: './list.component.html', | |
styleUrls: ['./list.component.scss'], | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getProducts(): Observable<(Products_allProducts_data)[]> { | |
return this.apollo.watchQuery<Products>({query: this.query, pollInterval: 120000}).valueChanges.pipe( | |
map(result => result.data.allProducts.data), | |
filter((x): x is Products_allProducts_data[] => x !== null) | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apollo client:codegen \ | |
--header="Authorization: Bearer REPLACE_WITH_YOUR_FAUNA_SECRET_KEY" \ | |
--endpoint=https://graphql.fauna.com/graphql \ | |
--target=typescript |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This file can be replaced during build by using the `fileReplacements` array. | |
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. | |
// The list of file replacements can be found in `angular.json`. | |
export const environment = { | |
production: false, | |
FAUNA_KEY: 'the secret fauna key you copied earlier', | |
FAUNA_ENDPOINT: 'https://graphql.fauna.com/graphql', | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NgModule } from '@angular/core'; | |
import { CommonModule } from '@angular/common'; | |
import { environment } from 'src/environments/environment'; | |
import { ApolloBoost, ApolloBoostModule } from 'apollo-angular-boost'; | |
import { HttpClientModule } from '@angular/common/http'; | |
@NgModule({ | |
declarations: [], | |
imports: [CommonModule], | |
exports: [HttpClientModule, ApolloBoostModule], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Product { | |
name: String! | |
price: [Price!]! @relation | |
} | |
type Store { | |
name: String! | |
price: Price | |
} |
NewerOlder